cminject.fields package¶
A collection of physical acceleration fields, containing (at least)
Base classes for doing interpolation on a field defined by a regular grid of samples
Fields for fluid flow forces
A field that is defined in terms of a single function – useful for e.g. including gravity
Fields for photophoretic forces
Submodules¶
cminject.fields.fluid_flow module¶
Acceleration fields that model flowing fluids.
- class cminject.fields.fluid_flow.DragForceInterpolationField(filename, *args, **kwargs)¶
Bases:
cminject.fields.regular_grid_interpolation.RegularGridInterpolationField,abc.ABCA base class for any field that calculates a drag force based on a regular interpolation grid field and some model. The method that needs to be implemented is calculate_drag_force.
- get_local_properties(phase_space_position: numpy.array) Tuple[float, numpy.array]¶
Gets the properties of the fluid at the phase-space position (position + velocity) of a particle.
- Parameters
phase_space_position – The phase-space position of the particle.
- Returns
A 2-tuple, containing * The pressure of the fluid at that point * The relative velocity (v_fluid - v_particle)
- interpolate(position: numpy.array) numpy.array¶
Return the raw results of interpolating on this field at a certain position in space.
- Parameters
position – The position in space to interpolate this field for.
- Returns
An np.array containing all interpolated quantities at the given position, or
An np.array containing only NaN, if the interpolator raised a
ValueError.
- is_particle_inside(position: numpy.array, time: float) bool¶
Akin to a Boundary’s is_particle_inside method. Used by GridFieldBasedBoundary to delegate the calculation of the result to a RegularGridInterpolationField. :param position: The particle’s position. :param time: The current time. :return: True if the particle is inside this field, False otherwise.
- property z_boundary: Tuple[float, float]¶
Returns the Z boundary of this Z-bounded object.
- Returns
A tuple of floats, the first entry being z_min, the second being z_max.
- class cminject.fields.fluid_flow.MolecularFlowDragForceField(filename: str, m_gas: Optional[float] = None, temperature: Optional[float] = None, *args, **kwargs)¶
Bases:
cminject.fields.fluid_flow.DragForceInterpolationFieldA flow field that calculates a drag force exerted on a particle, based on the Epstein force for high velocities and interpolation on a grid defined by an HDF5 file like comsol_hdf5_tools.txt_to_hdf5 outputs.
- calculate_acceleration(particle: cminject.particles.spherical.ThermallyConductiveSphericalParticle, time: float) numpy.array¶
Calculates the drag force using Epstein’s law for spherical particles in molecular flow with corrections for high velocities
- class cminject.fields.fluid_flow.StokesDragForceField(filename: str, dynamic_viscosity: Optional[float] = None, m_gas: Optional[float] = None, temperature: Optional[float] = None, slip_correction_model: Optional[str] = None, slip_correction_scale: float = 1.0, *args, **kwargs)¶
Bases:
cminject.fields.fluid_flow.DragForceInterpolationFieldA flow field that calculates a drag force exerted on a particle, based on the stokes force and interpolation on a grid defined by an HDF5 file like comsol_hdf5_tools.txt_to_hdf5 outputs.
- calc_slip_correction(pressure: float, particle_radius: float) float¶
Calculates the slip correction factor with temperature corrections. Works for models ‘4_kelvin’ at 4K, and ‘room_temp’ at 293.15K.
Note
This method is replaced at runtime with a concrete implementation for the chosen slip correction model, to avoid the overhead of choosing at every call.
- calculate_acceleration(particle: cminject.particles.spherical.SphericalParticle, time: float) numpy.array¶
Calculates the drag force using Stokes’ law for spherical particles in continuum
cminject.fields.function_based module¶
- class cminject.fields.function_based.FunctionField(function: Callable[[cminject.base.Particle, float], numpy.array])¶
Bases:
cminject.base.FieldA simple stateless Field based on a function to calculate the acceleration.
Implies infinite extent of the field, i.e. a particle is never considered to be outside the field’s boundary. The number of dimensions of this field is not validated, meaning the given function must be able to handle particles of the experiment dimensionality.
- calculate_acceleration(particle: cminject.base.Particle, time: float) numpy.array¶
Calculates an acceleration for one particle based on the particle’s current properties and the current time. This acceleration will be integrated for in each time step and thus “applied” to the particle.
- Parameters
particle – The Particle to calculate this Field’s acceleration for.
time – The time to calculate the acceleration for.
- Returns
A (n,)-shaped numpy array describing the acceleration exerted on the particle. n is the number of spatial dimensions of the experiment.
- property z_boundary: Tuple[float, float]¶
Returns the Z boundary of this Z-bounded object.
- Returns
A tuple of floats, the first entry being z_min, the second being z_max.
cminject.fields.photophoresis module¶
Fields modeling photophoresis phenomena.
- class cminject.fields.photophoresis.DesyatnikovPhotophoreticLaserField(gas_viscosity: float, gas_temperature: float, gas_thermal_conductivity: float, gas_density: Union[float, Tuple[float, cminject.fields.fluid_flow.DragForceInterpolationField]], gas_mass: float, beam_power: float, beam_waist_radius: float, beam_lambda: float = 5.23e-07, z_position: float = 0.0)¶
Bases:
cminject.fields.photophoresis.VortexBeamPhotophoreticForceFieldA Field that represents the acceleration exerted by an LG01 beam (in radial coordinates), according to the model by Desyatnikov, 2009.
- calculate_acceleration(particle: cminject.particles.spherical.ThermallyConductiveSphericalParticle, time: float) numpy.array¶
Calculates an acceleration for one particle based on the particle’s current properties and the current time. This acceleration will be integrated for in each time step and thus “applied” to the particle.
- Parameters
particle – The Particle to calculate this Field’s acceleration for.
time – The time to calculate the acceleration for.
- Returns
A (n,)-shaped numpy array describing the acceleration exerted on the particle. n is the number of spatial dimensions of the experiment.
- kappa(particle_radius: float, particle_thermal_conductivity: float, gas_density: float)¶
The phenomenological constant kappa, as described in Desyatnikov’s 2009 paper.
- pp_force(a: float, r: float, z: float, k_f: float, rho: float) numpy.array¶
Calculates the axial component of the photophoretic force, based on an approximation by Desyatnikov, 2009, for small particles with a << w.
- Parameters
a – The particle radius.
r – The particle’s radial offset relative to the beam axis.
z – The particle’s axial offset relative to the beam origin.
k_f – The particle’s thermal conductivity.
rho – The local density of the gas at (r, z).
- Returns
A tuple containing the transverse (first element) and axial (second element) components of the photophoretic force.
- w(z: float)¶
- class cminject.fields.photophoresis.VortexBeamPhotophoreticForceField(beam_power: float, beam_waist_radius: float, beam_lambda: float = 5.23e-07)¶
Bases:
cminject.base.Field,abc.ABCA base class that can calculate the irradiance of a Laguerre-Gaussian order 1 vortex beam, for a point in radial coordinates (r, z).
- calculate_vortex_irradiance(r: float, z: float)¶
Vortex irradiance distribution for a vortex beam propagating from (0,0) along the z axis towards the positive. The beam is radially symmetric around the Z axis, so only r and z are passed.
- Parameters
r – The polar radius in the plane transverse to the optical Z axis
z – The position on the optical Z axis
- z_boundary = (inf, -inf)¶
cminject.fields.regular_grid_interpolation module¶
Fields that use interpolation on a regular spatial grid to determine some number of quantities at any point in space that they are defined at.
- class cminject.fields.regular_grid_interpolation.RegularGridInterpolationField(filename: str, offset: Optional[numpy.array] = None, *args, **kwargs)¶
Bases:
cminject.base.Field,cminject.utils.global_config.ConfigSubscriber,abc.ABCA generic base class for fields that calculate a force based on interpolation within some n-dimensional regular grid. This class provides an interpolate method; the actual calculation of acceleration has to be defined in a subclass and should use the result of this method.
- config_change(key: cminject.utils.global_config.ConfigKey, value: Any)¶
Will be called whenever the value of any subscribed key changes. Will be called once at the time of subscribing, IF the value for the subscribed key(s) is not None.
- Parameters
key – The ConfigKey that the change occurred for.
value – The new value of the configuration value stored for the key
key.
- Returns
Nothing (unused).
- abstract is_particle_inside(position: numpy.array, time: float) bool¶
Akin to a Boundary’s is_particle_inside method. Used by GridFieldBasedBoundary to delegate the calculation of the result to a RegularGridInterpolationField. :param position: The particle’s position. :param time: The current time. :return: True if the particle is inside this field, False otherwise.
- property z_boundary: Tuple[float, float]¶
Returns the Z boundary of this Z-bounded object.
- Returns
A tuple of floats, the first entry being z_min, the second being z_max.