From 925d69409922aa9db6dc3d9d8a74237fcdb04305 Mon Sep 17 00:00:00 2001 From: Sylvain Tricot Date: Tue, 30 Nov 2021 16:26:10 +0100 Subject: [PATCH] Added 'other_parameters' keyword to any scan. This keyword is a dictionary allowing any option to be passed to Phagen or Spec just before runing the calculation. It is usefull to pass special options that are for example set automatically otherwise. --- src/msspec/calculator.py | 33 ++++++++++++++++++++++----------- src/msspec/parameters.py | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/msspec/calculator.py b/src/msspec/calculator.py index 9f9ef2b..d78a1c9 100644 --- a/src/msspec/calculator.py +++ b/src/msspec/calculator.py @@ -616,7 +616,7 @@ class _PED(_MSCALCULATOR): def _get_scan(self, scan_type='theta', phi=0, theta=np.linspace(-70, 70, 141), level=None, kinetic_energy=None, data=None, - malloc={}): + malloc={}, other_parameters={}): LOGGER.info("Computting the %s scan...", scan_type) if data: self.iodata = data @@ -651,6 +651,13 @@ class _PED(_MSCALCULATOR): self.spectroscopy_parameters.set_parameter('level', level) + # It is still possible to change any parameter right before + # runing Phagen or Spec + for k, v in other_parameters.items(): + grp_str, parma_str = k.split('.') + grp = getattr(self, grp_str) + grp.set_parameter(parma_str, v, force=True) + self.get_tmatrix() self.run_spec(malloc) @@ -852,7 +859,7 @@ class _PED(_MSCALCULATOR): return self.iodata def get_scattering_factors(self, level='1s', kinetic_energy=None, - data=None): + data=None, **kwargs): """Computes the scattering factors of all prototypical atoms in the cluster. @@ -871,11 +878,12 @@ class _PED(_MSCALCULATOR): """ data = self._get_scan(scan_type='scatf', level=level, data=data, - kinetic_energy=kinetic_energy) + kinetic_energy=kinetic_energy, **kwargs) return data def get_theta_scan(self, phi=0, theta=np.linspace(-70, 70, 141), - level=None, kinetic_energy=None, data=None): + level=None, kinetic_energy=None, data=None, + **kwargs): """Computes a polar scan of the emitted photoelectrons. :param phi: The azimuthal angle in degrees. See @@ -892,11 +900,12 @@ class _PED(_MSCALCULATOR): """ data = self._get_scan(scan_type='theta', level=level, theta=theta, - phi=phi, kinetic_energy=kinetic_energy, data=data) + phi=phi, kinetic_energy=kinetic_energy, + data=data, **kwargs) return data def get_phi_scan(self, phi=np.linspace(0, 359, 359), theta=0, - level=None, kinetic_energy=None, data=None): + level=None, kinetic_energy=None, data=None, **kwargs): """Computes an azimuthal scan of the emitted photoelectrons. :param phi: All the values of the azimuthal angle to be computed. See @@ -913,12 +922,13 @@ class _PED(_MSCALCULATOR): """ data = self._get_scan(scan_type='phi', level=level, theta=theta, - phi=phi, kinetic_energy=kinetic_energy, data=data) + phi=phi, kinetic_energy=kinetic_energy, + data=data, **kwargs) return data def get_theta_phi_scan(self, phi=np.linspace(0, 360), theta=np.linspace(0, 90, 45), level=None, - kinetic_energy=None, data=None): + kinetic_energy=None, data=None, **kwargs): """Computes a stereographic scan of the emitted photoelectrons. The azimuth ranges from 0 to 360° and the polar angle ranges from 0 to @@ -935,11 +945,11 @@ class _PED(_MSCALCULATOR): """ data = self._get_scan(scan_type='theta_phi', level=level, theta=theta, phi=phi, kinetic_energy=kinetic_energy, data=data, - malloc={'NPH_M': 8000}) + malloc={'NPH_M': 8000}, **kwargs) return data def get_energy_scan(self, phi=0, theta=0, - level=None, kinetic_energy=None, data=None): + level=None, kinetic_energy=None, data=None, **kwargs): """Computes an energy scan of the emitted photoelectrons. :param phi: All the values of the azimuthal angle to be computed. See @@ -956,7 +966,8 @@ class _PED(_MSCALCULATOR): """ data = self._get_scan(scan_type='energy', level=level, theta=theta, - phi=phi, kinetic_energy=kinetic_energy, data=data) + phi=phi, kinetic_energy=kinetic_energy, + data=data, **kwargs) return data diff --git a/src/msspec/parameters.py b/src/msspec/parameters.py index 51a3817..8a682f4 100644 --- a/src/msspec/parameters.py +++ b/src/msspec/parameters.py @@ -1540,7 +1540,7 @@ class CalculationParameters(BaseParameters): Parameter('cutoff_factor', types=(int, float), limits=(1e-4, 999.9999), default=0.01, private=False), Parameter('mean_free_path', types=(int, float, str), - default='SeahDench', allowed_values=('mono', 'SeahDench'), + default='SeahDench', #allowed_values=('mono', 'SeahDench'), doc=""" The electron mean free path value. You can either: - Enter a value (in Angströms), in this case any value <=0 will disable the damping