Skip to content
8 changes: 4 additions & 4 deletions tofu/physics_tools/electrons/emission/_pbs_d2cross.pbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#PBS -l instance_type=c7i.8xlarge
#PBS -l walltime=1500:00:00
#PBS -P sparc-design
#PBS -N d2cross_61x160x161_EH
#PBS -o d2cross_61x160x161_EH.out
#PBS -e d2cross_61x160x161_EH.err
#PBS -N d2cross_91x160x161_EH
#PBS -o d2cross_91x160x161_EH.out
#PBS -e d2cross_91x160x161_EH.err
#PBS -m abe
#PBS -l base_os=ubuntu2404
#PBS -l instance_ami=ami-0d63a2e021bce724d
Expand All @@ -17,4 +17,4 @@ source ~/.bashrc
# Beware: PBS does not expand the tilde ~/ => full explicit path needed
export PBS_O_WORKDIR="/data/home/dvezinet/projects/tofu/tofu/physics_tools/electrons/emission"
cd ${PBS_O_WORKDIR}/
python _pbs_d2cross.py -nEph 161 -nEe0 160 -ntheta 61 -v EH
python _pbs_d2cross.py -nEph 161 -nEe0 160 -ntheta 91 -nthetae 51 -ndphi 91 -v EH
27 changes: 27 additions & 0 deletions tofu/physics_tools/electrons/emission/_pbs_d2cross.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def main(
nEph=None,
nEe0=None,
ntheta=None,
nthetae=None,
ndphi=None,
version=None,
ddef=None,
):
Expand Down Expand Up @@ -72,9 +74,12 @@ def main(
E_e0_eV=E_e0_eV[None, :, None],
E_ph_eV=E_ph_eV[None, None, :],
theta_ph=theta_ph[:, None, None],
nthetae=nthetae,
ndphi=ndphi,
save=True,
verb=2,
version=version,
source='cfsem',
)

# ------------------
Expand Down Expand Up @@ -107,6 +112,8 @@ def main(
'nEph': 401,
'nEe0': 400,
'ntheta': 181,
'nthetae': None,
'ndphi': None,
'version': 'EH',
}

Expand Down Expand Up @@ -147,6 +154,26 @@ def main(
default=ddef['ntheta'],
)

# nthetae
parser.add_argument(
'-nthetae',
'--nthetae',
type=int,
help='Number of np.linspace(0, np.pi, nthetae) (rad)',
required=False,
default=ddef['nthetae'],
)

# ndphi
parser.add_argument(
'-ndphi',
'--ndphi',
type=int,
help='Number of np.linspace(-np.pi, np.pi, ndphi) (rad)',
required=False,
default=ddef['ndphi'],
)

# version
parser.add_argument(
'-v',
Expand Down
41 changes: 31 additions & 10 deletions tofu/physics_tools/electrons/emission/_xray_thin_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,19 @@ def _hyp2F1(
aa[ind], bb[ind], cc[ind], zz[ind],
)

# ----------------
# source = cfsem
# ----------------

elif source == 'cfsem':

out = dfunc['cfsem'].hyp2f1(
aa.astype('complex128'),
bb.astype('complex128'),
cc.astype('complex128'),
zz.astype('complex128'),
)

# ----------------
# source = 1/z or z/(z-1)
# ----------------
Expand Down Expand Up @@ -1681,18 +1694,24 @@ def _hyp2f1_check(specfunc_dir=None):
dfunc['specfunc'] = specfunc

# --------
# mpmath
# mpmath and cfsem
# --------

try:
import mpmath
dfunc['mpmath'] = mpmath
except Exception:
msg = (
"\n_hyp2F1: mpmath not available\n"
"See https://pypi.org/project/mpmath/\n"
)
dwarn['mpmath'] = msg
ls = ['mpmath', 'cfsem']

for ss in ls:
try:
if ss == 'mpmath':
import mpmath as sour
else:
import cfsem as sour
dfunc[ss] = sour
except Exception:
msg = (
f"\n_hyp2F1: {ss} not available\n"
"See https://pypi.org/project/{ss}/\n"
)
dwarn[ss] = msg

# --------
# lok
Expand All @@ -1703,6 +1722,8 @@ def _hyp2f1_check(specfunc_dir=None):
lok.insert(0, 'specfunc')
if dwarn.get('mpmath') is None:
lok.insert(0, 'mpmath')
if dwarn.get('cfsem') is None:
lok.insert(0, 'cfsem')

return lok, dwarn, dfunc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@


# Integration
_NTHETAE = 31
_NDPHI = 51
_NTHETAE = 91
_NDPHI = 181

# VERSION
_VERSION = 'BHE' # good compromise
_VERSION = 'EH' # best with cfsem.hyp2f1()


# Default naming
Expand Down Expand Up @@ -229,20 +229,28 @@ def _check(
# integers
# -----------

# nthetae_def and ndphi_def
if theta_ph.size == np.prod(theta_ph.shape):
nthetae_def = theta_ph.size
ndphi_def = 2*(theta_ph.size - 1) + 1
else:
nthetae_def = _NTHETAE
ndphi_def = _NDPHI

# nthetae
nthetae = ds._generic_check._check_var(
nthetae, 'nthetae',
types=int,
sign='>0',
default=_NTHETAE,
default=nthetae_def,
)

# ndphi
ndphi = ds._generic_check._check_var(
ndphi, 'ndphi',
types=int,
sign='>0',
default=_NDPHI,
default=ndphi_def,
)

# ------------
Expand Down
Loading