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

EELS&CL for particles inside arbitrary host medium #314

Open
wants to merge 102 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
1f0b959
Created new branch EELS for simulations of EELS spectra (issue 155)
to266 Jan 15, 2014
9bae8c9
Added electron beam B_ELECTRON with required subroutines and constant…
to266 Jan 16, 2014
aed6adc
added EELS probability calculations. The iterative solver somehow doe…
to266 Jan 20, 2014
0b61b09
Corrected misstypes and found a bug regarding not passing values if n…
to266 Jan 22, 2014
030495e
merge with trunk
to266 Feb 24, 2014
b30be95
resolved abs(x) error, changed variables to doubles where complex not…
to266 Feb 24, 2014
c435482
Update .gitignore
alkichigin Mar 3, 2020
156099d
Update .gitignore
alkichigin Mar 6, 2020
444207c
Revert "Update .gitignore"
alkichigin Mar 26, 2020
37bb556
Revert "Update .gitignore"
alkichigin Mar 26, 2020
ef325e1
Added beam of an electron
alkichigin Apr 10, 2020
da7f496
added fortran library for Bessel functions calculation
alkichigin Apr 23, 2020
9024ff7
For now the code is proven to work for vacuum
alkichigin May 21, 2020
adc78e6
added eelsprob calculation
alkichigin Jun 2, 2020
51391a0
added EELS support for non-absorbing host medium
alkichigin Jun 3, 2020
fe19f7c
Merge remote-tracking branch 'upstream/master'
alkichigin Jun 19, 2020
8425ef2
Renamed Peels_au to Peels_ev
alkichigin Jun 19, 2020
891b519
merging from upstream
alkichigin Jun 20, 2020
db57873
merging from upstream
alkichigin Jun 20, 2020
8e6c1c5
manually copying doc/history from upstream/master
alkichigin Jun 20, 2020
5067d9d
manually copying non-src files from upstream/master
alkichigin Jun 20, 2020
fc8c314
manually copying src files from upstream\master
alkichigin Jun 20, 2020
379a461
manually copying calculator.c from upstream/master
alkichigin Jun 20, 2020
6c8fdd8
manually deleted merge-related older code parts
alkichigin Jun 21, 2020
2a4d744
manually deleted merge-related code parts
alkichigin Jun 21, 2020
2d61a77
deleted bash script
alkichigin Jun 21, 2020
008060f
fixed minor mistakes, now the code works for EELS on a sphere
alkichigin Jun 21, 2020
9b6c0fd
Update .gitignore
alkichigin Jun 21, 2020
d7e5198
Update .gitignore
alkichigin Jun 21, 2020
041d62a
minor fixes
alkichigin Jun 21, 2020
8e377a6
trancated special_functions.f90
alkichigin Jun 21, 2020
0ec7159
minor fixes
alkichigin Jun 21, 2020
80552ad
Update crosssec.h
alkichigin Jun 21, 2020
a189d22
minor fixes
alkichigin Jun 21, 2020
e5b9496
re-written for the code to work with -prop and -orient, but not teste…
alkichigin Jun 25, 2020
9a3f6e8
optimized GenerateB
alkichigin Jun 26, 2020
531ba06
simplified the code
alkichigin Jun 26, 2020
d65de1f
Manually replaced files from alkichigin/master. Now EELS works in non…
alkichigin Jun 26, 2020
8a5fcb3
merged from upstream and edited decr according to issue #271
alkichigin Jun 28, 2020
613e3ad
Added cathodoluminescence
alkichigin Jul 4, 2020
ea18d69
golden master
alkichigin Jul 20, 2020
aaa66fd
Merge branch 'eels'
alkichigin Jul 22, 2020
83b910f
Merge pull request #1 from adda-team/master
Sunmosk Aug 4, 2020
84749d8
minor tweaks
alkichigin Aug 15, 2020
41a89ff
uploading older version of PAW
alkichigin Aug 26, 2020
3645dee
uploading current PAW v0.3
alkichigin Aug 26, 2020
a6d6853
Added the -mhost option, which enables the non-unity refractive index…
Sunmosk Nov 2, 2020
09efd72
Update crosssec.c
Sunmosk Nov 20, 2020
03189b0
Beta 0.000001
Sunmosk Nov 23, 2020
d327d26
ADDA Wrapper 0.4
alkichigin Dec 29, 2020
8f193b8
removing simulation results
alkichigin Dec 29, 2020
4589ebb
Merge remote-tracking branch 'upstream/master'
alkichigin Dec 29, 2020
eeede49
minor changes
alkichigin Jan 26, 2021
e27071d
Merge remote-tracking branch 'upstream/master'
alkichigin Jan 26, 2021
3aaf891
small improvements
alkichigin Mar 27, 2021
e9247aa
Merge remote-tracking branch 'upstream/master'
alkichigin Mar 27, 2021
3fa7b2e
Merge remote-tracking branch 'sunmosk/master'
alkichigin Mar 27, 2021
f14bc4e
minor fixes
alkichigin Mar 27, 2021
e6f7949
minor fixes
alkichigin Mar 27, 2021
5adc7c9
fixed the bug with kd definition
alkichigin Mar 28, 2021
6c23476
minor change on the examples
alkichigin Mar 28, 2021
72cc273
ADDAWrapper 0.5
alkichigin Mar 30, 2021
86aa0f0
minor fixes
alkichigin Jun 9, 2021
3221b31
Merge remote-tracking branch 'upstream/master'
alkichigin Jun 9, 2021
347964a
ADDA Wrapper plots now uses Arial font
alkichigin Jul 29, 2021
d3aaebe
ADDA Wrapper plots are saved in svg format
alkichigin Jul 29, 2021
86a30f8
-beam_center option introduced
alkichigin Aug 3, 2021
c64dcac
Added -beam_center support for plane waves
alkichigin Aug 8, 2021
5f72571
Added -beam_center description to -h and logging alongside the beam p…
alkichigin Aug 9, 2021
595e344
Gaussian beam fix for -beam_center
alkichigin Aug 24, 2021
c3afaab
preparing merge from upsatream
alkichigin Nov 11, 2021
f9b4777
Merge remote-tracking branch 'upstream/master'
alkichigin Nov 11, 2021
a39dcc3
Modified definitions of cross sections + made kdX, kdY, kdZ doublecom…
Sunmosk Nov 24, 2021
0c5d913
removing .DS_Store
alkichigin Dec 14, 2021
823e209
Merge remote-tracking branch 'upstream/master'
alkichigin Dec 14, 2021
ae5d9fb
examples updated to igt_so
alkichigin Dec 15, 2021
bcc0c90
Merge pull request #1 from Sunmosk/master
alkichigin Dec 15, 2021
5a6dfd8
Cross sections are changed according to mhost, GenerateB and Peels/Pc…
alkichigin Jan 19, 2022
8a9ead2
moved ADDAwrapper to misc, fixed bug in crosssec.c
alkichigin Jan 25, 2022
922756b
Boolean absorbing_host, Solved problems with warnings due to doubleco…
Sunmosk Jan 25, 2022
63dbc96
Merge pull request #3 from alkichigin/master
Sunmosk Jan 25, 2022
2c150f7
Merge branch 'Some-Old-Code' into master
Sunmosk Jan 25, 2022
9e12cf3
minor fix
alkichigin Jan 27, 2022
c13917f
Merge pull request #2 from Sunmosk/master
alkichigin Jan 27, 2022
766a4db
Merge remote-tracking branch 'upstream/master'
alkichigin Jan 27, 2022
a03faed
Delete org.eclipse.cdt.core.prefs
alkichigin Jan 27, 2022
ac64e8c
merge upstream bugfixing
alkichigin Jan 27, 2022
3153101
Merge pull request #5 from alkichigin/master
Sunmosk Jan 27, 2022
4474872
Abs_cross fixed, volume integrals normalized to WaveNum0
Sunmosk Jan 27, 2022
e5a8161
Merge pull request #3 from Sunmosk/master
alkichigin Jan 28, 2022
2b0e969
warnings fix
alkichigin Jan 28, 2022
6103e4f
Adapted ADDAwrapper for Windows
alkichigin Feb 3, 2022
5c01797
Merge remote-tracking branch 'upstream/master'
alkichigin Feb 3, 2022
1f1c83b
Update ADDAwrapper.py
alkichigin Feb 3, 2022
133ef02
adda "varyany" to ADDAwrapper
alkichigin Feb 8, 2022
c967f03
Wrapper now plots in proper 10^-3 rather than former 1e-3
alkichigin Feb 17, 2022
2b8241c
ADDAwrapper now can visualize the dipole set
alkichigin Feb 21, 2022
f4ea2ec
minor fix
alkichigin Feb 21, 2022
5f70d0e
fixed bug
Sunmosk May 10, 2022
a07058d
minor updates
alkichigin Aug 3, 2022
d53d3ae
Merge pull request #4 from Sunmosk/master
alkichigin Aug 3, 2022
f552ad3
Merge remote-tracking branch 'upstream/master'
alkichigin Aug 3, 2022
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
Prev Previous commit
Next Next commit
added fortran library for Bessel functions calculation
  • Loading branch information
alkichigin committed Apr 23, 2020
commit da7f49639afc59286251c3922b3264c52c262ad3
67 changes: 39 additions & 28 deletions src/GenerateB.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
// system headers
#include <stdio.h>
#include <string.h>
#include <float.h>

// SEMI-GLOBAL VARIABLES

Expand All @@ -46,6 +47,8 @@ extern const char *beam_fnameY;
extern const char *beam_fnameX;
extern const opt_index opt_beam;

extern void cik01_(doublecomplex *z, doublecomplex *cbi0, doublecomplex *cdi0, doublecomplex *cbi1, doublecomplex *cdi1, doublecomplex *cbk0, doublecomplex *cdk0, doublecomplex *cbk1, doublecomplex *cdk1);

// used in CalculateE.c
double C0dipole,C0dipole_refl; // inherent cross sections of exciting dipole (in free space and addition due to surface)

Expand All @@ -72,6 +75,17 @@ static doublecomplex ktVec[3]; // k_tran/k0
static double p0; // amplitude of the incident dipole moment
static double e_energy; // kinetic energy of the electron
static doublecomplex m_host; // refractive index of the host medium
static doublecomplex eps_omega;// dielectric permittivity of the host medium
static doublecomplex gamma_eps;// gamma-epsilon is same as Lorentz factor, except the speed of light is the speed of light in the medium
static doublecomplex gamma_eps_inv;// 1/gamma_eps
static double omega; // angular frequency
static double v_electron; // speed of the electron
static doublecomplex e_inc_pr; // prefactor in the incident field of the electron
static doublecomplex e_om_v; // prefactor in an argument of a phase exponent in the incident field of the electron
static doublecomplex e_om_gv; // prefactor in an argument of the Bessel_K in the incident field of the electron
const double q_electron = -4.803204673e-10; //electric charge of an electron, esu
const double c_light = 29979245800; //speed of light in vacuum, cm/s
const double e_energy_rest = 510.99895; //Electron rest mass, keV
/* TO ADD NEW BEAM
* Add here all internal variables (beam parameters), which you initialize in InitBeam() and use in GenerateB()
* afterwards. If you need local, intermediate variables, put them into the beginning of the corresponding function.
Expand Down Expand Up @@ -197,9 +211,18 @@ void InitBeam(void)
beam_center_0[1] = beam_pars[2];
beam_center_0[2] = 0;
m_host = beam_pars[3] + 0*I; //complex number in the future
scale_x = 1e-4; //um/сm
scale_z = 1e-4; //um/сm
TestPositive(creal(m_host),"refractive index of the host medium");
omega = WaveNum*c_light*scale_z;
printf("Omega = %g\n", omega);
eps_omega = m_host*m_host;
v_electron = c_light*sqrt(1-pow((e_energy_rest/(e_energy+e_energy_rest)),2));
gamma_eps_inv = csqrt(1-pow((v_electron/c_light),2)*eps_omega);
gamma_eps = 1/gamma_eps_inv;
e_inc_pr = 2*q_electron*omega/(eps_omega*v_electron*v_electron*gamma_eps);
e_om_v = omega/v_electron;
e_om_gv = omega/(gamma_eps*v_electron);

symX = symY = symZ = symR = false; // symmetry is unlikely to happen
if (IFROOT) sprintf(beam_descr,"electron with energy %g keV in host medium with m_host=%g moving through (%g,%g,0)",e_energy,creal(m_host),COMP3V(beam_center_0));
return;
Expand Down Expand Up @@ -249,17 +272,12 @@ void GenerateB (const enum incpol which, // x - or y polarized incident light
doublecomplex psi0,Q,Q2;
doublecomplex v1[3],v2[3],v3[3],gt[6];
double ro,ro2,ro4;
double x,y,z,x2_s,xy_s,x0,y0,z0;
double x,y,z,x2_s,xy_s;
doublecomplex t1,t2,t3,t4,t5,t6,t7,t8,ctemp;
const double *ex; // coordinate axis of the beam reference frame
double ey[3];
double r1[3];
const char *fname;
double omega;
doublecomplex eps_omega, v_electron, gamma_eps;
const double q_electron = -4.803204673e-10; //electric charge of an electron, esu
const double c_light = 29979245800; //speed of light in vacuum, cm/s
const double e_energy_rest = 510.99895; //Electron rest mass, keV
/* TO ADD NEW BEAM
* Add here all intermediate variables, which are used only inside this function. You may as well use 't1'-'t8'
* variables defined above.
Expand Down Expand Up @@ -456,36 +474,29 @@ void GenerateB (const enum incpol which, // x - or y polarized incident light
}
return;
case B_ELECTRON:
x0 = beam_center_0[0];
y0 = beam_center_0[1];
z0 = beam_center_0[2];
omega = WaveNum*c_light;
eps_omega = m_host*m_host;
v_electron = c_light*sqrt(1-pow((e_energy_rest/(e_energy+e_energy_rest)),2));
gamma_eps = 1/csqrt(1-pow((v_electron/c_light),2)*eps_omega);

t1 = 2*q_electron*omega/(eps_omega*v_electron*v_electron*gamma_eps);
t2 = omega/v_electron;
t3 = omega/(gamma_eps*v_electron);

for (i=0;i<local_nvoid_Ndip;i++) {
j=3*i;
// set relative coordinates (in beam's coordinate system)
LinComb(DipoleCoord+j,beam_center,1,-1,r1);
x=DotProd(r1,ex)*scale_x;
y=DotProd(r1,ey)*scale_x;
x=DotProd(r1,ex)*scale_z;
y=DotProd(r1,ey)*scale_z;
z=DotProd(r1,prop)*scale_z;
ro=sqrt(x*x+y*y);

t4 = imExp(t2*(z-z0));
t5 = 1; //BesselK(1,phi), temporarily not done yet
t6 = 1; //BesselK(0,phi), temporarily not done yet
if (ro < DBL_EPSILON) LogError(ONE_POS,"electron hit a dipole, this is currently not supported, ro = %e", ro);

e_om_gv *= ro;
cik01_(&e_om_gv, &t1, &t1, &t1, &t1, &t7, &t1, &t8, &t1);
//LogError(ONE_POS,"\nK0(%g + I*%g) = %.16e + I*%.16e\nK1(%g + I*%g) = %.16e + I*%.1e", creal(e_om_gv), cimag(e_om_gv), creal(t7), cimag(t7), creal(e_om_gv), cimag(e_om_gv), creal(t8), cimag(t8));

t4 = imExp(e_om_v*z);

v1[0] = (x/ro)*t4*t8; //E_inc_x
v1[1] = (y/ro)*t4*t8; //E_inc_y
v1[2] = -I*gamma_eps_inv*t4*t7; //E_inc_z

v1[0] = t1*((x-x0)/ro)*t4*t5; //E_inc_x
v1[1] = t1*((y-y0)/ro)*t4*t5; //E_inc_y
v1[2] = -I * (t1/gamma_eps)*t4*t6; //E_inc_z

cvMultScal_cmplx(1,v1,b+j); //Присвоить значения из v1 в правильное место b1
cvMultScal_cmplx(e_inc_pr,v1,b+j);
}
return;
case B_READ:
Expand Down
5 changes: 3 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ CSOURCE := ADDAmain.c CalculateE.c calculator.c chebyshev.c cmplx.c comm.c cross
timing.c vars.c
# Fortran files are located in src/fort folder, other files may be added below
FSOURCE := d07hre.f d09hre.f d113re.f d132re.f dadhre.f dchhre.f dcuhre.f dfshre.f dinhre.f drlhre.f dtrhre.f \
propaesplibreintadda.f
F90SOURCE :=
propaesplibreintadda.f
F90SOURCE := special_functions.f90
# C++ files are located in src/cpp folder, other files may be added below
CPPSOURCE :=

Expand Down Expand Up @@ -371,6 +371,7 @@ ifeq ($(COMPILER),gnu)
# Use gfortran if available (GCC 4 and later), otherwise try g77
ifeq ($(shell which gfortran > /dev/null 2>&1 && echo 0),0)
CF := gfortran
LDFLAGS += -L/usr/local/gfortran/lib
FLIBS += -lgfortran
else
# This is not expected to work for f90 sources but we keep it for now
Expand Down
Loading