Skip to content

Commit

Permalink
Merge branch 'python-interface' of https://github.com/empa-scientific…
Browse files Browse the repository at this point in the history
…-it/cleedpy into python-interface
  • Loading branch information
baffelli committed Jan 11, 2024
2 parents cd8df17 + 95fd60a commit db72b58
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
16 changes: 16 additions & 0 deletions cleedpy/cleed/src/leed.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ real ** leed(

struct eng_str eng;

// Printing stuff
inp_showbop(bulk, over, phs_shifts);
return 0;

eng.ini = energy_list[0];
eng.stp = energy_list[1] - energy_list[0];
eng.fin = energy_list[energy_list_size-1];
Expand Down Expand Up @@ -235,3 +239,15 @@ real ** leed(

return iv_curves;
}


int my_test_function(int a, int b, struct cryst_str * bulk){
printf("vr: %lf\n", bulk->vr);
printf("vi: %lf\n", bulk->vi);

printf("\nbulk 2-dim. unit cell:\n");
printf("a1: (%7.4lf %7.4lf)\n", bulk->a[1]*BOHR, bulk->a[3]*BOHR);
printf("a2: (%7.4lf %7.4lf)\n", bulk->a[2]*BOHR, bulk->a[4]*BOHR);

return a+b;
}
8 changes: 0 additions & 8 deletions cleedpy/cleed/test_cleed.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,6 @@ FILE *res_stream;
mk_cg_coef (2*v_par->l_max);
mk_ylm_coef(2*v_par->l_max);

#ifdef CONTROL
fprintf(STDCTR, "(LEED_TEMP): E_ini = %.1f, E_fin = %.1f, E_stp %.1f\n",
eng->ini*HART, eng->fin*HART, eng->stp*HART);

//fprintf(STDCTR, "(LEED_TEMP): lset = %d\n", n_set);
#endif


// Construct energy list
energy_list_size = (eng->fin - eng->ini)/eng->stp + 1;
energy_list = (real *) malloc(energy_list_size * sizeof(real));
Expand Down
18 changes: 16 additions & 2 deletions cleedpy/interface/cleed.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ class Crystal(Structure):
("vr", c_double),
("vi", c_double),
("temp", c_double),
# Not used anymore
# From here
("n_rot", c_int),
("rot_axis", c_double * 4),
("n_mir", c_int),
("m_plane", POINTER(c_double)),
("alpha", POINTER(c_double)),
("symmetry", c_int),
# To here
("a", c_double * 5),
("a_1", c_double * 5),
("area", c_double),
Expand Down Expand Up @@ -180,9 +183,20 @@ def generate_crystal_structure(input: AtomParametersVariants) -> Crystal:
raise ValueError("Not implemented")

def call_cleed():
path = Path(cleedpy.__file__).parent / "cleed" / "build" / "lib" / "libcleed.so"
path = Path(cleedpy.__file__).parent / "cleed" / "build" / "lib" / "libcleed.dylib"
lib = cdll.LoadLibrary(str(path))
lib.leed

lib.my_test_function.argtypes = [c_int, c_int, POINTER(Crystal)]
lib.my_test_function.restype = c_int

bulk = Crystal()
bulk.vr = 1.0
bulk.vi = 2.0
bulk.temp = 300.0

bulk.a = (0.0, 1.0, 2.0, 3.0, 4.0)

print("Restul is ", lib.my_test_function(1, 2, bulk))


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion examples/cleed_example_old/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export CLEED_PHASE=./PHASE
EXECUTABLE=../../cleedpy/cleed/build/test_cleed
EXECUTABLE=../../cleedpy/cleed/build/bin/test_cleed

${EXECUTABLE} -i Ni111_Cu.inp

0 comments on commit db72b58

Please sign in to comment.