From 05f115a6b416dd912f9fb7c21b842fffe5b92de6 Mon Sep 17 00:00:00 2001 From: David Grote Date: Thu, 1 Jun 2023 11:41:18 -0700 Subject: 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 --- Python/pywarpx/picmi.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'Python/pywarpx/picmi.py') 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 -- cgit v1.2.3