diff options
author | 2023-06-01 11:41:18 -0700 | |
---|---|---|
committer | 2023-06-01 11:41:18 -0700 | |
commit | 05f115a6b416dd912f9fb7c21b842fffe5b92de6 (patch) | |
tree | b5e1ba5392aa9bd7daf94b635ca7656047fa3463 /Python/pywarpx/picmi.py | |
parent | 5f053ec122bcf751bcc2fb41660e43ac120c26c0 (diff) | |
download | WarpX-05f115a6b416dd912f9fb7c21b842fffe5b92de6.tar.gz WarpX-05f115a6b416dd912f9fb7c21b842fffe5b92de6.tar.zst WarpX-05f115a6b416dd912f9fb7c21b842fffe5b92de6.zip |
Update picmi interface for MCCCollisions (#3953)
* Allow string expressions for MCCCollisions background density and temperature
* Add check of whether value is str since special behavior is needed
Diffstat (limited to 'Python/pywarpx/picmi.py')
-rw-r--r-- | Python/pywarpx/picmi.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index f9bb6404c..2e3df7153 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -1272,11 +1272,11 @@ class MCCCollisions(picmistandard.base._ClassWithInit): species: species instance The species involved in the collision - background_density: float - The density of the background + background_density: float or string + The density of the background. An string expression as a function of (x, y, z, t) can be used. - background_temperature: float - The temperature of the background + background_temperature: float or string + The temperature of the background. An string expression as a function of (x, y, z, t) can be used. scattering_processes: dictionary The scattering process to use and any needed information @@ -1306,8 +1306,14 @@ class MCCCollisions(picmistandard.base._ClassWithInit): collision = pywarpx.Collisions.newcollision(self.name) collision.type = 'background_mcc' collision.species = self.species.name - collision.background_density = self.background_density - collision.background_temperature = self.background_temperature + if isinstance(self.background_density, str): + collision.__setattr__('background_density(x,y,z,t)', self.background_density) + else: + collision.background_density = self.background_density + if isinstance(self.background_temperature, str): + collision.__setattr__('background_temperature(x,y,z,t)', self.background_temperature) + else: + collision.background_temperature = self.background_temperature collision.background_mass = self.background_mass collision.ndt = self.ndt |