diff --git a/cleedpy/cleed/src/leed.c b/cleedpy/cleed/src/leed.c index cc98c63..c3c0dbb 100644 --- a/cleedpy/cleed/src/leed.c +++ b/cleedpy/cleed/src/leed.c @@ -1,14 +1,15 @@ #include "leed.h" real ** leed( - struct cryst_str * bulk, - struct cryst_str *over, - struct phs_str *phs_shifts, - int energy_list_size, - real *energy_list, - struct var_str *v_par, - FILE *res_stream + char * bul_file, + char * par_file, + char *res_file ){ + struct cryst_str *bulk=NULL; + struct cryst_str *over=NULL; + struct phs_str *phs_shifts=NULL; + struct var_str *v_par=NULL; + struct beams_str * beams_now=NULL; struct beams_str * beams_set=NULL; @@ -21,11 +22,12 @@ real ** leed( int i_layer; int energy_index; int n_set; - + int energy_list_size; + real *energy_list; real energy; real vec[4]; - float **iv_curves=NULL; + real **iv_curves=NULL; mat R_bulk=NULL, R_tot=NULL; mat Amp=NULL; @@ -33,26 +35,44 @@ real ** 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; + struct eng_str *eng=NULL; + + FILE *res_stream; + + // Read input parameters + printf("HERE %s\n", bul_file); + 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); + inp_showbop(bulk, over, phs_shifts); + + + // 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_indexini + energy_index * eng->stp; + } // Printing stuff - printf("TEST SASHA\n"); inp_showbop(bulk, over, phs_shifts); - printf("END TEST SASHA\n"); + res_stream = fopen(res_file,"w"); + + out_head(bulk, res_stream); + mk_cg_coef (2*v_par->l_max); // Setting up Clebsh Gordan coefficients as global variables. mk_ylm_coef(2*v_par->l_max); // Setting up spherical harmonics coefficients as global variables. - 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); + n_set = bm_gen(&beams_all, bulk, v_par, eng->fin); + out_bmlist(&beams_out, beams_all, eng, res_stream); /* Main Energy Loop */ @@ -243,6 +263,8 @@ real ** leed( } /* end of energy loop */ + fclose(res_stream); + return iv_curves; } diff --git a/cleedpy/cleed/test_cleed.c b/cleedpy/cleed/test_cleed.c index 2fde91c..575078a 100644 --- a/cleedpy/cleed/test_cleed.c +++ b/cleedpy/cleed/test_cleed.c @@ -4,198 +4,14 @@ #include "gh_stddef.h" #include "leed.h" -#define CTR_NORMAL 998 -#define CTR_EARLY_RETURN 999 +main(){ + // File names + char *bul_file="Ni111_Cu.inp"; // bulk and non-geometrical parameters. + char *par_file="Ni111_Cu.inp"; // overlayer parameters of all parameters (if bul_file does not exist) + char *res_file="leed.res"; // output file containing the LEED intensities -main(int argc, char *argv[])/*Perform a LEED calculation for anisotropic vibrations a general case */ -{ -struct cryst_str *bulk; -struct cryst_str *over; -struct phs_str *phs_shifts; -struct beam_str *beams_all; -struct beam_str *beams_out; -struct beam_str *beams_now; -struct beam_str *beams_set; -struct var_str *v_par; -struct eng_str *eng; - -mat Tpp, Tmm, Rpm, Rmp; -mat Tpp_s, Tmm_s, Rpm_s, Rmp_s; -mat R_bulk, R_tot; -mat Amp; - -int ctr_flag; -int i_c, i_arg; -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]; - -char linebuffer[STRSZ]; - -char bul_file[STRSZ]; /* input/output files */ -char par_file[STRSZ]; -char pro_name[STRSZ]; -char res_file[STRSZ]; - -FILE *pro_stream; -FILE *res_stream; - - Tpp = Tmm = Rpm = Rmp = NULL; - Tpp_s = Tmm_s = Rpm_s = Rmp_s = NULL; - R_bulk = R_tot = NULL; - Amp = NULL; - - bulk = over = NULL; - phs_shifts = NULL; - beams_all = NULL; - beams_now = NULL; - beams_set = NULL; - beams_out = NULL; - v_par = NULL; - eng = NULL; - - -/********************************************************************* - Preset parameters (file names) set by arguments -*********************************************************************/ - - ctr_flag = CTR_NORMAL; - - strncpy(bul_file,"---", STRSZ); - - strncpy(par_file,"---", STRSZ); - strncpy(res_file,"leed.res", STRSZ); - strncpy(pro_name,"leed.pro", STRSZ); - -/********************************************************************* - Decode arguments: - - -b - (optional input file) bulk and non-geometrical - parameters. - -i - (mandatory input file) overlayer parameters of all - parameters (if bul_file does not exist). - -o - (output file) IV output. -*********************************************************************/ - - for (i_arg = 1; i_arg < argc; i_arg++) - { - if(*argv[i_arg] != '-') - { - fprintf(STDERR,"*** error (LEED_TEMP):\tsyntax error: %s\n", argv[i_arg]); - fprintf(STDERR,"\tusage: \tleed -i -o "); - fprintf(STDERR," [-b -e]\n"); - exit(1); - } - else - { -/* Read parameter input file */ - if(strncmp(argv[i_arg], "-b", 2) == 0) - { - i_arg++; - strncpy(bul_file, argv[i_arg], STRSZ); - } /* -b */ - -/* Read parameter input file */ - if(strncmp(argv[i_arg], "-i", 2) == 0) - { - i_arg++; - strncpy(par_file, argv[i_arg], STRSZ); - } /* -i */ - -/* Read and open results file */ - if(strncmp(argv[i_arg], "-o", 2) == 0) - { - i_arg++; - strncpy(res_file, argv[i_arg], STRSZ); - if ((res_stream = fopen(res_file, "w")) == NULL) - { - fprintf(STDERR, - "*** error (LEED_TEMP): could not open output file \"%s\"\n", - res_file); - exit(1); - } - } /* -o */ - -/* Read parameter input file */ - if(strncmp(argv[i_arg], "-e", 2) == 0) - { - ctr_flag = CTR_EARLY_RETURN; - } /* -e */ - - - } /* else */ - } /* for i_arg */ - -/********************************************************************* - Check arguments: - - check existence of par_file. - - if bul_file is not specified, use par_file instead. - - check existence of res_file. -*********************************************************************/ - - if(strncmp(par_file, "---", 3) == 0) - { - fprintf(STDERR,"*** error (LEED_TEMP): no parameter input file (option -i) specified\n"); - exit(1); - } - - if(strncmp(bul_file, "---", 3) == 0) - { - strncpy(bul_file, par_file, STRSZ); - } - - if(strncmp(res_file, "leed.res", 8) == 0) - { - fprintf(STDWAR, "* warning (LEED_TEMP): no output file (option -o) specified\n\toutput will be written to file \"%s\"\n", res_file); - if ((res_stream = fopen(res_file,"w")) == NULL) - { - fprintf(STDERR, "*** error (LEED_TEMP): could not open output file \"%s\"\n",res_file); - exit(1); - } - } - -/********************************************************************* - Read input parameters -*********************************************************************/ - - 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); - - inp_showbop(bulk, over, phs_shifts); - - if( ctr_flag == CTR_EARLY_RETURN ) - { - fprintf(STDCTR, "(LEED_TEMP): EARLY RETURN \n"); - exit(0); - } - - out_head (bulk, res_stream); - -/********************************************************************* - Prepare some often used parameters. -*********************************************************************/ - - // 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_indexini + energy_index * eng->stp; - } - - leed(bulk, over, phs_shifts, energy_list_size, energy_list, v_par, res_stream); - printf("Finished leed\n"); - fprintf(STDCTR, "(LEED): end of energy loop: close files\n"); - - fclose(res_stream); + // Calculate LEED intensities + leed(bul_file, par_file, res_file); exit(0); - -} /* end of main */ +} diff --git a/examples/cleed_example_old/run.sh b/examples/cleed_example_old/run.sh index c85ff53..5d7c51b 100755 --- a/examples/cleed_example_old/run.sh +++ b/examples/cleed_example_old/run.sh @@ -1,4 +1,4 @@ export CLEED_PHASE=./PHASE EXECUTABLE=../../cleedpy/cleed/bin/test_cleed -${EXECUTABLE} -i Ni111_Cu.inp +${EXECUTABLE}