Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic tests for the example calculations #55

Merged
merged 7 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions cleedpy/cleed/include/leed_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ int inpovlay_sym(struct cryst_str *, struct atom_str *);
/* read a matrix with specified l1 m1 l2 m2 */
mat inp_mat_lm(mat , int , const char *);

/* read phase shifts; file linpphase.c */
int inp_phase_nd( char * , real * , int , struct phs_str **);
int upd_phase( int );

/* read bulk parameters; file linprdbul.c */
int inp_rdbul_nd(struct cryst_str ** , struct phs_str ** , char *, char *);
int inp_rdbul_nd(struct cryst_str ** , struct phs_str ** , char *, char *, int *);
int inp_rdbulsym(struct cryst_str ** , struct phs_str ** , char *);

/* read overlayer parameters; file linprdovl.c */
int inp_rdovl (struct cryst_str ** , struct phs_str ** , struct cryst_str * , char *);
int inp_rdovl_nd(struct cryst_str **, struct phs_str **, struct cryst_str *, char *, char *);
int inp_rdovl_nd(struct cryst_str **, struct phs_str **, struct cryst_str *, char *, char *, int *);
int inp_rdovlsym(struct cryst_str ** , struct phs_str ** , struct cryst_str * , char *);
/* read other parameters; file linprdpar.c */
int inp_rdpar(struct var_str **, struct eng_str **, struct cryst_str * , char *);
Expand Down
5 changes: 3 additions & 2 deletions cleedpy/cleed/src/leed.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ CleedResult leed(char * par_file, char * bul_file, char *phase_path)
int i_layer;
int energy_index;
int n_set;
int n_phase_shifts=0;
real energy;
real vec[4];
mat R_bulk=NULL, R_tot=NULL;
Expand All @@ -66,9 +67,9 @@ CleedResult leed(char * par_file, char * bul_file, char *phase_path)
struct eng_str *eng=NULL;

// Read input parameters
inp_rdbul_nd(&bulk, &phs_shifts, bul_file, phase_path);
inp_rdbul_nd(&bulk, &phs_shifts, bul_file, phase_path, &n_phase_shifts);
inp_rdpar(&v_par, &eng, bulk, bul_file);
inp_rdovl_nd(&over, &phs_shifts, bulk, par_file, phase_path);
inp_rdovl_nd(&over, &phs_shifts, bulk, par_file, phase_path, &n_phase_shifts);
inp_showbop(bulk, over, phs_shifts);
for (i=0; (phs_shifts + i)->lmax != I_END_OF_LIST; i++)
print_phase_shift(phs_shifts[i]);
Expand Down
46 changes: 9 additions & 37 deletions cleedpy/cleed/src/linpphasend.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
GH/15.07.03
file contains function:

upd_phase
Update the number of phase shifts.
inp_phase_nd
Read phase shifts from an input file and store them.

Changes:

GH/04.07.94 - Creation
Expand All @@ -31,30 +26,8 @@
#include "leed.h"
#include "leed_def.h"

static int i_phase = 0; /* number of atom types */

/********************************************************************/

int upd_phase( int n)

/*********************************************************************
Update the number of phase shifts i_phase

INPUT:
int n number i_phase will be set to.

RETURN VALUE:
i_phase (i.e. equal to the argument)

*********************************************************************/
{
i_phase = n;
return(i_phase);
} /* end of function upd_phase */

/********************************************************************/

int inp_phase_nd( char * filename, real * dr, int t_type, struct phs_str **p_phs_shifts)
int inp_phase_nd( char * filename, real * dr, int t_type, struct phs_str **p_phs_shifts, int *i_phase)
/*********************************************************************

Read phase shifts from an input file and store them.
Expand Down Expand Up @@ -88,11 +61,11 @@ int inp_phase_nd( char * filename, real * dr, int t_type, struct phs_str **p_phs
real eng_scale;
real faux;

if(i_phase > 0)
if((*i_phase) > 0)
{
/* Compare filename, dr, and t_type with previous phaseshifts. Return the
corresponding phase shift number if the same combination has already been read. */
for(i=0; i< i_phase; i++)
for(i=0; i< (*i_phase); i++)
if( (!strcmp( (*p_phs_shifts + i)->input_file, filename) ) &&
( R_fabs(dr[1] - (*p_phs_shifts + i)->dr[1]) < GEO_TOLERANCE ) &&
( R_fabs(dr[2] - (*p_phs_shifts + i)->dr[2]) < GEO_TOLERANCE ) &&
Expand All @@ -103,21 +76,21 @@ int inp_phase_nd( char * filename, real * dr, int t_type, struct phs_str **p_phs
return(i);
break;
}
i_phase ++;
*p_phs_shifts = (struct phs_str *)realloc(*p_phs_shifts, (i_phase + 1) * sizeof(struct phs_str) );
(*i_phase) ++;
*p_phs_shifts = (struct phs_str *)realloc(*p_phs_shifts, ((*i_phase) + 1) * sizeof(struct phs_str) );
}
else
{
i_phase ++;
(*i_phase) ++;
*p_phs_shifts = (struct phs_str *) malloc( 2 * sizeof(struct phs_str) );
}

// Terminate list of phase shifts.

(*(p_phs_shifts) + i_phase)->lmax = I_END_OF_LIST;
(*(p_phs_shifts) + (*i_phase))->lmax = I_END_OF_LIST;


phs_shifts = *(p_phs_shifts) + i_phase-1;
phs_shifts = *(p_phs_shifts) + (*i_phase)-1;

// Write dr and t_type to phs_shifts.
for(i=0; i<=3; i++) phs_shifts->dr[i] = dr[i];
Expand Down Expand Up @@ -185,7 +158,6 @@ int inp_phase_nd( char * filename, real * dr, int t_type, struct phs_str **p_phs
phs_shifts->energy = (real *)calloc( neng, sizeof(real) );
phs_shifts->pshift = (real *)calloc( neng * nl, sizeof(real) );


for( i_eng = 0; (i_eng < neng) && (fgets(linebuffer, STRSZ, inp_stream) != NULL); i_eng ++)
{
sscanf(linebuffer, "%le", phs_shifts->energy+i_eng);
Expand Down Expand Up @@ -219,5 +191,5 @@ int inp_phase_nd( char * filename, real * dr, int t_type, struct phs_str **p_phs
fprintf(STDWAR, " expected energies: %3d, found: %3d, file: %s\n", neng, i_eng+1, filename);
}

return(i_phase - 1);
return((*i_phase) - 1);
} /* end of function inp_phase */
Loading
Loading