diff --git a/tofu/physics_tools/electrons/emission/_pbs_d2cross.pbs b/tofu/physics_tools/electrons/emission/_pbs_d2cross.pbs index 087b994ab..00ec3e47a 100644 --- a/tofu/physics_tools/electrons/emission/_pbs_d2cross.pbs +++ b/tofu/physics_tools/electrons/emission/_pbs_d2cross.pbs @@ -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 @@ -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 diff --git a/tofu/physics_tools/electrons/emission/_pbs_d2cross.py b/tofu/physics_tools/electrons/emission/_pbs_d2cross.py index aa7838af3..2e6673b1a 100644 --- a/tofu/physics_tools/electrons/emission/_pbs_d2cross.py +++ b/tofu/physics_tools/electrons/emission/_pbs_d2cross.py @@ -27,6 +27,8 @@ def main( nEph=None, nEe0=None, ntheta=None, + nthetae=None, + ndphi=None, version=None, ddef=None, ): @@ -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', ) # ------------------ @@ -107,6 +112,8 @@ def main( 'nEph': 401, 'nEe0': 400, 'ntheta': 181, + 'nthetae': None, + 'ndphi': None, 'version': 'EH', } @@ -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', diff --git a/tofu/physics_tools/electrons/emission/_xray_thin_target.py b/tofu/physics_tools/electrons/emission/_xray_thin_target.py index f9f4e4dc2..419b929d6 100644 --- a/tofu/physics_tools/electrons/emission/_xray_thin_target.py +++ b/tofu/physics_tools/electrons/emission/_xray_thin_target.py @@ -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) # ---------------- @@ -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 @@ -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 diff --git a/tofu/physics_tools/electrons/emission/_xray_thin_target_integrated.py b/tofu/physics_tools/electrons/emission/_xray_thin_target_integrated.py index 047ed221e..65fd77d26 100644 --- a/tofu/physics_tools/electrons/emission/_xray_thin_target_integrated.py +++ b/tofu/physics_tools/electrons/emission/_xray_thin_target_integrated.py @@ -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 @@ -229,12 +229,20 @@ 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 @@ -242,7 +250,7 @@ def _check( ndphi, 'ndphi', types=int, sign='>0', - default=_NDPHI, + default=ndphi_def, ) # ------------