Skip to content

Commit

Permalink
Simplify the API of the leed function.
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Jan 10, 2024
1 parent 642a18a commit 33f2391
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ FILE *res_stream;
set exit status explicitly
********************************************/

printf("The original code is working fine.\n");

exit(0);

} /* end of main */
29 changes: 22 additions & 7 deletions cleedpy/cleed/src/leed.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#include "leed.h"

float ** leed(
real ** leed(
struct cryst_str * bulk,
struct cryst_str *over,
struct phs_str *phs_shifts,
struct beam_str *beams_all,
struct beam_str * beams_out,
int n_set,
struct eng_str *eng,
int energy_list_size,
real *energy_list,
struct var_str *v_par,
FILE *res_stream
){

struct beams_str * beams_now=NULL;
struct beams_str * beams_set=NULL;
struct beam_str * beams_out=NULL;
struct beam_str *beams_all=NULL;

int n_beams_now, n_beams_set;

int i_c, i_set, offset;
int i_layer;
int energy_index;
int n_set;

real energy;
real vec[4];
Expand All @@ -30,10 +33,22 @@ float ** leed(
mat Tpp=NULL, Tmm=NULL, Rpm=NULL, Rmp=NULL;
mat Tpp_s=NULL, Tmm_s=NULL, Rpm_s=NULL, Rmp_s=NULL;

struct eng_str eng;

eng.ini = energy_list[0];
eng.stp = energy_list[1] - energy_list[0];
eng.fin = energy_list[energy_list_size-1];


/* Generate beams out */
n_set = bm_gen(&beams_all, bulk, v_par, eng.fin);
out_bmlist(&beams_out, beams_all, &eng, res_stream);


/* Main Energy Loop */
for(energy=eng->ini; energy<eng->fin+E_TOLERANCE; energy+= eng->stp){
pc_update(v_par, phs_shifts, energy);

for(energy_index=0; energy_index<energy_list_size; energy_index++){
pc_update(v_par, phs_shifts, energy_list[energy_index]);
n_beams_now = bm_select(&beams_now, beams_all, v_par, bulk->dmin);

/*********************************************************************
Expand Down
20 changes: 14 additions & 6 deletions cleedpy/cleed/test_cleed.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ int n_beams_now, n_beams_set;
int i_set, n_set, offset;
int i_layer;

int energy_list_size, energy_index;
real *energy_list;

real energy;
real vec[4];

Expand Down Expand Up @@ -219,7 +222,6 @@ FILE *res_stream;
inp_rdbul_nd(&bulk, &phs_shifts, bul_file);
inp_rdpar(&v_par, &eng, bulk, bul_file);
inp_rdovl_nd(&over, &phs_shifts, bulk, par_file);
n_set = bm_gen(&beams_all, bulk, v_par, eng->fin);

inp_showbop(bulk, over, phs_shifts);

Expand All @@ -230,7 +232,6 @@ FILE *res_stream;
}

out_head (bulk, res_stream);
out_bmlist(&beams_out, beams_all, eng, res_stream);

/*********************************************************************
Prepare some often used parameters.
Expand All @@ -243,14 +244,20 @@ FILE *res_stream;
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): n_set = %d\n", n_set);
//fprintf(STDCTR, "(LEED_TEMP): lset = %d\n", n_set);
#endif


printf("Starting leed\n");
leed(bulk, over, phs_shifts, beams_all, beams_out, n_set, eng, v_par, res_stream);
printf("Finished leed\n");
// Construct energy list
energy_list_size = (eng->fin - eng->ini)/eng->stp + 1;
energy_list = (real *) malloc(energy_list_size * sizeof(real));
for (energy_index=0; energy_index<energy_list_size; energy_index++)
{
energy_list[energy_index] = eng->ini + energy_index * eng->stp;
}

leed(bulk, over, phs_shifts, energy_list_size, energy_list, v_par, res_stream);
printf("Finished leed\n");

#ifdef CONTROL_IO
fprintf(STDCTR, "(LEED): end of energy loop: close files\n");
Expand All @@ -272,6 +279,7 @@ FILE *res_stream;
set exit status explicitly
********************************************/

printf("The new code is working\n");
exit(0);

} /* end of main */
Loading

0 comments on commit 33f2391

Please sign in to comment.