pyoomph.materials.generic module

class pyoomph.materials.generic.BaseGasProperties[source]

Bases: MaterialProperties

A base class for defining gaseous materials.

dynamic_viscosity: Union[Expression, int, float]

The dynamic viscosity of the gas.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

initial_condition: Dict[str, Union[Expression, int, float]]

The initial condition of the material. Will be set automatically when using e.g. the Mixture() function to assemble a mixture of pure components.

is_pure: Optional[bool]

Whether the material is pure or mixed. If the material is mixed, the components of the mixture should be specified in the components attribute. This should be treated as read-only property.

mass_density: Union[Expression, int, float]

The mass density of the material.

molar_mass: Union[Expression, int, float]

The molecular weight of the material, used to calculate the mole fractions from the mass fractions.

name: str

Unique name of the material. Names should be unique within the same state of matter (e.g. liquid, gas, solid), and the same material name for the same material should be used for different states of matter.

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

specific_heat_capacity: Union[Expression, int, float]

The specific heat capacity of the material.

thermal_conductivity: Union[Expression, int, float]

The thermal conductivity of the material.

class pyoomph.materials.generic.BaseInterfaceProperties(sideA, sideB)[source]

Bases: object

Base class for interface properties.

set_mass_transfer_model(mdl)[source]

Sets the mass transfer model.

Return type:

None

surface_tension: Union[Expression, int, float]

The surface tension of this interface

class pyoomph.materials.generic.BaseLiquidProperties[source]

Bases: MaterialProperties

A base class for defining liquid materials.

default_surface_tension: Dict[Literal['gas', 'solid', 'liquid'], Union[Expression, int, float, None]]

Default surface tension of the liquid. This is a dictionary with the keys "gas", "solid", and "liquid". The value for each key is the surface tension of the liquid with the respective other phase.

dynamic_viscosity: Union[Expression, int, float]

The dynamic viscosity of the liquid.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

get_vapor_mass_concentration(component, relative_humidity_for_far_field=None, temperature=None, at_mixture_composition=True)[source]

Calculates the saturation vapor concentration \(c_{sat}\) for the given component in [kg/m^3]. If relative_humidity_for_far_field is set, it does not apply Raoult’s law, but uses the relative humidity to calculate the vapor concentration in the far field

Parameters:
  • component (str) – Name of the component.

  • relative_humidity_for_far_field (Union[Expression, int, float, None]) – Relative humidity in the far field. If set, it is used to calculate the vapor concentration of the pure vapor in the far field.

  • temperature (Union[Expression, int, float, None]) – Temperature at which to calculate the vapor concentration. If not set, the temperature from the initial condition is used.

  • at_mixture_composition (Union[bool, Dict[str, Union[Expression, int, float]]]) – If set to True, the vapor concentration is calculated at the mixture initial composition. If set to a dictionary, the vapor concentration is calculated at the given composition.

initial_condition: Dict[str, Union[Expression, int, float]]

The initial condition of the material. Will be set automatically when using e.g. the Mixture() function to assemble a mixture of pure components.

is_pure: Optional[bool]

Whether the material is pure or mixed. If the material is mixed, the components of the mixture should be specified in the components attribute. This should be treated as read-only property.

mass_density: Union[Expression, int, float]

The mass density of the material.

molar_mass: Union[Expression, int, float]

The molecular weight of the material, used to calculate the mole fractions from the mass fractions.

name: str

Unique name of the material. Names should be unique within the same state of matter (e.g. liquid, gas, solid), and the same material name for the same material should be used for different states of matter.

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

set_reference_scaling_to_problem(problem, temperature=None, **kwargs)[source]

Set the reference scaling to nondimensionalize a dimensional problem.

Parameters:
  • problem (Problem) – The problem for which the reference scaling is being set.

  • temperature (Union[Expression, int, float, None]) – The temperature to be used for nondimensionalization. If not provided, the initial condition temperature will be used.

  • **kwargs (Union[Expression, int, float]) – Additional parameters to be used for scaling.

Raises:

RuntimeError – If at least two of the scales ‘temporal’, ‘spatial’, and ‘velocity’ are not set in the problem before.

specific_heat_capacity: Union[Expression, int, float]

The specific heat capacity of the material.

thermal_conductivity: Union[Expression, int, float]

The thermal conductivity of the material.

class pyoomph.materials.generic.BaseMixedProperties(pure_props)[source]

Bases: object

A base class used for defining mixtures of pure components.

get_diffusion_coefficient(n1, n2=None, default=None)[source]

Returns the diffusion coefficient between two components. If only one component is given, the diagonal element is returned.

Parameters:
  • n1 (str) – Component name for the diffusive flux.

  • n2 (Optional[str]) – Potential second component name for an off-diagonal diffusion coefficient. If None, the diagonal element is returned.

  • default (Union[Expression, int, float, None]) – Default value to return if the diffusion coefficient is not set.

Return type:

Union[Expression, int, float, None]

Returns:

The diffusion coefficient.

get_diffusive_mass_flux_for(n)[source]

Returns the diffusive mass flux for one component according to Fick’s law.

Return type:

Union[Expression, int, float]

get_mass_fraction_field(name, **kwargs)[source]

Returns the mass fraction field for the given component.

Return type:

Expression

get_mole_fraction_field(name, **kwargs)[source]

Returns the mole fraction field for the given component.

Return type:

Expression

get_pure_component(name, raise_error=False)[source]

Returns the pure component properties for the specified component.

Parameters:
  • name (str) – Name of the pure component.

  • raise_error (bool) – Raise an error if the component is not present in the mixture. Otherwise, None is returned.

Return type:

Optional[MaterialProperties]

Returns:

The pure properties of the component.

make_static(cond=None, temperature=None)[source]

This will make the mixture static, i.e. all mass fraction fields will be replaced by their values from the given condition. This is useful for to remove advection-diffusion equations if the composition stays homogeneous.

Parameters:
  • cond (Optional[Dict[str, Union[Expression, int, float]]]) – Optional condition, otherwise the initial_condition is used.

  • temperature (Union[Expression, int, float, None]) – Optional temperature

passive_field: Optional[str]

The passive field of the mixture. This is the field for which a advective-diffusive equation is not solved, since we can calculate it from the mass fractions of the other components.

set_by_weighted_average(what=None, fraction_type='mass_fraction')[source]

Calculate a property by just taking the weighted average of the properties of all pure components. :type what: Optional[str] :param what: Property or expression to be calculated. If None, all properties that are present in all pure components are calculated. :type fraction_type: str :param fraction_type: Which fraction to weight the average with. Can be "mass_fraction" (default) or "mole_fraction".

Raises:
  • ValueError – _description_

  • ValueError – _description_

set_diffusion_coefficient(arg1, arg2=None, arg3=None)[source]

Set the diffusion coefficient for the specified component in the mixture.

Parameters:
  • arg1 (Union[Expression, int, float, str]) – Either the diagonal diffusion coefficient for all components or the name of the component to set the diffusion coefficient.

  • arg2 (Union[Expression, int, float, None, str]) – Either the diagonal diffusion coeffient for the component given as first argument or the name of the second component or None for off-diagonal diffusion.

  • arg3 (Union[Expression, int, float, None]) – The diffusion coefficient for off-diagonal diffusion.

class pyoomph.materials.generic.BaseSolidProperties[source]

Bases: MaterialProperties

A base class for defining solid materials.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

initial_condition: Dict[str, Union[Expression, int, float]]

The initial condition of the material. Will be set automatically when using e.g. the Mixture() function to assemble a mixture of pure components.

is_pure: Optional[bool]

Whether the material is pure or mixed. If the material is mixed, the components of the mixture should be specified in the components attribute. This should be treated as read-only property.

mass_density: Union[Expression, int, float]

The mass density of the material.

molar_mass: Union[Expression, int, float]

The molecular weight of the material, used to calculate the mole fractions from the mass fractions.

name: str

Unique name of the material. Names should be unique within the same state of matter (e.g. liquid, gas, solid), and the same material name for the same material should be used for different states of matter.

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

specific_heat_capacity: Union[Expression, int, float]

The specific heat capacity of the material.

thermal_conductivity: Union[Expression, int, float]

The thermal conductivity of the material.

class pyoomph.materials.generic.DefaultLiquidGasInterface(phaseA, phaseB, surfactant_dict)[source]

Bases: LiquidGasInterfaceProperties

Default liquid-gas interface properties, which just uses the default surface tension of the liquid phase against gas.

Parameters:
evaluate_at_initial_surfactant_concentrations(expr)

Evaluates an expression, e.g. the surface tension, at the initial surfactant concentrations.

Return type:

Union[Expression, int, float]

get_gas_properties()

Returns the gas properties.

Return type:

Union[PureGasProperties, MixtureGasProperties]

get_latent_heat_of(name)

Returns the latent heat of evaporation for a component.

Return type:

Union[Expression, int, float]

get_liquid_properties()

Returns the liquid properties.

Return type:

Union[PureLiquidProperties, MixtureLiquidProperties]

get_mass_transfer_model()

Returns the mass transfer model.

Return type:

Optional[MassTransferModelBase]

get_surface_diffusivity(surfactant_name)

Returns the surface diffusivity of a surfactant.

Return type:

Union[Expression, int, float, None]

set_mass_transfer_model(mdl)

Sets the mass transfer model.

Return type:

None

set_surface_diffusivity(surfactant_name, expr)

Sets the surface diffusivity of a surfactant.

surface_tension: Union[Expression, int, float]

The surface tension of this interface

surfactant_adsorption_rate: Dict[str, Union[Expression, int, float]]

The rate of surfactant adsorption and desorption, merged in a single expression per surfactant

class pyoomph.materials.generic.LiquidGasInterfaceProperties(phaseA, phaseB, surfactant_dict)[source]

Bases: BaseInterfaceProperties

A class representing the properties of a liquid-gas interface.

Parameters:
evaluate_at_initial_surfactant_concentrations(expr)[source]

Evaluates an expression, e.g. the surface tension, at the initial surfactant concentrations.

Return type:

Union[Expression, int, float]

gas_components: Union[str, Set[str], None] = None

The components of the gas phase

get_gas_properties()[source]

Returns the gas properties.

Return type:

Union[PureGasProperties, MixtureGasProperties]

get_latent_heat_of(name)[source]

Returns the latent heat of evaporation for a component.

Return type:

Union[Expression, int, float]

get_liquid_properties()[source]

Returns the liquid properties.

Return type:

Union[PureLiquidProperties, MixtureLiquidProperties]

get_mass_transfer_model()[source]

Returns the mass transfer model.

Return type:

Optional[MassTransferModelBase]

get_surface_diffusivity(surfactant_name)[source]

Returns the surface diffusivity of a surfactant.

Return type:

Union[Expression, int, float, None]

liquid_components: Union[str, Set[str], None] = None

The components of the liquid phase

set_mass_transfer_model(mdl)

Sets the mass transfer model.

Return type:

None

set_surface_diffusivity(surfactant_name, expr)[source]

Sets the surface diffusivity of a surfactant.

surface_tension: Union[Expression, int, float]

The surface tension of this interface

surfactant_adsorption_rate: Dict[str, Union[Expression, int, float]]

The rate of surfactant adsorption and desorption, merged in a single expression per surfactant

surfactants: Union[Set[str], str, None] = None

The surfactants at the interface

class pyoomph.materials.generic.MaterialProperties[source]

Bases: object

Base class for all material properties. This class should not be instantiated directly, but rather one of its subclasses should be used. However, this class allows to register new material properties and interfaces using the @MaterialProperties.register() decorator (see register()) on the definition of the subclass.

components: Set[str] = {}

In case of a mixture, the components of the mixture. Should be set as class-variable in the subclass.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)[source]

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

initial_condition: Dict[str, Union[Expression, int, float]]

The initial condition of the material. Will be set automatically when using e.g. the Mixture() function to assemble a mixture of pure components.

is_pure: Optional[bool]

Whether the material is pure or mixed. If the material is mixed, the components of the mixture should be specified in the components attribute. This should be treated as read-only property.

mass_density: Union[Expression, int, float]

The mass density of the material.

molar_mass: Union[Expression, int, float]

The molecular weight of the material, used to calculate the mole fractions from the mass fractions.

name: str

Unique name of the material. Names should be unique within the same state of matter (e.g. liquid, gas, solid), and the same material name for the same material should be used for different states of matter.

classmethod register(*, override=False)[source]

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)[source]

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)[source]

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

specific_heat_capacity: Union[Expression, int, float]

The specific heat capacity of the material.

state_of_matter: Optional[str]

State of matter of the material. This should be treated as read-only property.

thermal_conductivity: Union[Expression, int, float]

The thermal conductivity of the material.

pyoomph.materials.generic.Mixture(mdef, temperature=None, quantity='mass_fraction', pressure=101324.99999999999999 * second**-2 * meter**-1 * kilogram)[source]

Returns a gas or liquid mixture from the given mixture definition components or a single material properties object.

Parameters:
  • mdef (Union[MixtureDefinitionComponents, MixtureDefinitionComponent, MaterialProperties, BaseLiquidProperties, BaseGasProperties, BaseSolidProperties, PureSolidProperties, PureLiquidProperties, PureGasProperties, MixtureLiquidProperties, MixtureGasProperties]) – Either a pure substance or a mixture like get_pure_liquid("water")+0.5*get_pure_liquid("ethanol").

  • temperature (Union[Expression, int, float, None]) – The temperature of the mixture. Used for potential initial conditions and required if you want to use e.g. volume fractions or relative humidity as mixture quantity.

  • quantity (Literal['mass_fraction', 'wt', 'mole_fraction', 'volume_fraction', 'relative_humidity', 'RH']) – Specifies the quantity definition of the mixture. Can be either "mass_fraction", "volume_fraction", "molar_fraction", or "relative_humidity".

  • pressure (Union[Expression, int, float]) – Absolute pressure. Necessary for particular conversions.

Return type:

Union[MaterialProperties, BaseLiquidProperties, BaseGasProperties, BaseSolidProperties, PureSolidProperties, PureLiquidProperties, PureGasProperties, MixtureLiquidProperties, MixtureGasProperties]

Returns:

The properties of the mixture from the material library.

class pyoomph.materials.generic.MixtureGasProperties(pure_props)[source]

Bases: BaseGasProperties, BaseMixedProperties

Class to define gas mixtures.

Parameters:

pure_props (Dict[str, MaterialProperties]) – Pure component properties, will be passed when mixing the gaseous mixture with the Mixture() function.

dynamic_viscosity: Union[Expression, int, float]

The dynamic viscosity of the gas.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

get_diffusion_coefficient(n1, n2=None, default=None)

Returns the diffusion coefficient between two components. If only one component is given, the diagonal element is returned.

Parameters:
  • n1 (str) – Component name for the diffusive flux.

  • n2 (Optional[str]) – Potential second component name for an off-diagonal diffusion coefficient. If None, the diagonal element is returned.

  • default (Union[Expression, int, float, None]) – Default value to return if the diffusion coefficient is not set.

Return type:

Union[Expression, int, float, None]

Returns:

The diffusion coefficient.

get_diffusive_mass_flux_for(n)

Returns the diffusive mass flux for one component according to Fick’s law.

Return type:

Union[Expression, int, float]

get_mass_fraction_field(name, **kwargs)

Returns the mass fraction field for the given component.

Return type:

Expression

get_mole_fraction_field(name, **kwargs)

Returns the mole fraction field for the given component.

Return type:

Expression

get_pure_component(name, raise_error=False)

Returns the pure component properties for the specified component.

Parameters:
  • name (str) – Name of the pure component.

  • raise_error (bool) – Raise an error if the component is not present in the mixture. Otherwise, None is returned.

Return type:

Optional[MaterialProperties]

Returns:

The pure properties of the component.

make_static(cond=None, temperature=None)

This will make the mixture static, i.e. all mass fraction fields will be replaced by their values from the given condition. This is useful for to remove advection-diffusion equations if the composition stays homogeneous.

Parameters:
  • cond (Optional[Dict[str, Union[Expression, int, float]]]) – Optional condition, otherwise the initial_condition is used.

  • temperature (Union[Expression, int, float, None]) – Optional temperature

mass_density_from_ideal_gas_law(pressure=field(absolute_pressure, < code=0, tags=>), temperature=field(temperature, < code=0, tags=>))[source]

Returns the mass density by assuming the ideal gas law. :type pressure: Union[Expression, int, float] :param pressure: Either a constant pressure or, by default, a potentially varying pressure given by var("absolute_pressure"). :type temperature: Union[Expression, int, float] :param temperature: Either a constant temperature or, by default, a potentially varying temperature given by var("temperature").

Returns:

The mass density according to the ideal gas law.

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

set_by_weighted_average(what=None, fraction_type='mass_fraction')

Calculate a property by just taking the weighted average of the properties of all pure components. :type what: Optional[str] :param what: Property or expression to be calculated. If None, all properties that are present in all pure components are calculated. :type fraction_type: str :param fraction_type: Which fraction to weight the average with. Can be "mass_fraction" (default) or "mole_fraction".

Raises:
  • ValueError – _description_

  • ValueError – _description_

set_diffusion_coefficient(arg1, arg2=None, arg3=None)

Set the diffusion coefficient for the specified component in the mixture.

Parameters:
  • arg1 (Union[Expression, int, float, str]) – Either the diagonal diffusion coefficient for all components or the name of the component to set the diffusion coefficient.

  • arg2 (Union[Expression, int, float, None, str]) – Either the diagonal diffusion coeffient for the component given as first argument or the name of the second component or None for off-diagonal diffusion.

  • arg3 (Union[Expression, int, float, None]) – The diffusion coefficient for off-diagonal diffusion.

set_diffusion_coefficient_by_Fuller_eq(for_dilute_gas, dominant_gas=None)[source]

Sets the diffusion coefficient by the Fuller equation. This is a simple approximation for the Fickian diffusion in gas mixtures. The equation is based on the diffusion volumes of the gases. See:

  • Fuller, E. N. and Giddings, J. C. 1965. J. Gas Chromatogr., 3: 222

  • Fuller, E. N., Ensley, K. and Giddings, J. C. 1969. J. Phys. Chem., 75: 3679

  • Fuller, E. N., Schettler, P. D. and Giddings, J. C. 1966. Ind. Eng. Chem., 58: 18

set_mass_density_from_ideal_gas_law()[source]

Sets the mass density by using mass_density_from_ideal_gas_law().

class pyoomph.materials.generic.MixtureLiquidProperties(pure_props)[source]

Bases: BaseLiquidProperties, BaseMixedProperties

Class to define liquid mixtures.

Parameters:

pure_props (Dict[str, MaterialProperties]) – Pure component properties, will be passed when mixing the gaseous mixture with the Mixture() function.

activity_coefficients: Dict[str, Union[Expression, int, float]]

A dict holding the activity coefficients given by the name of each pure component.

default_surface_tension: Dict[Literal['gas', 'solid', 'liquid'], Union[Expression, int, float, None]]

Default surface tension of the liquid. This is a dictionary with the keys "gas", "solid", and "liquid". The value for each key is the surface tension of the liquid with the respective other phase.

dynamic_viscosity: Union[Expression, int, float]

The dynamic viscosity of the liquid.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

get_diffusion_coefficient(n1, n2=None, default=None)

Returns the diffusion coefficient between two components. If only one component is given, the diagonal element is returned.

Parameters:
  • n1 (str) – Component name for the diffusive flux.

  • n2 (Optional[str]) – Potential second component name for an off-diagonal diffusion coefficient. If None, the diagonal element is returned.

  • default (Union[Expression, int, float, None]) – Default value to return if the diffusion coefficient is not set.

Return type:

Union[Expression, int, float, None]

Returns:

The diffusion coefficient.

get_diffusive_mass_flux_for(n)

Returns the diffusive mass flux for one component according to Fick’s law.

Return type:

Union[Expression, int, float]

get_latent_heat_of_evaporation(name)[source]

Returns the latent heat of evaporation for a given component. Falls back to the pure component if not changed specifically via set_latent_heat_of_evaporation().

Return type:

Union[Expression, int, float, None]

get_mass_fraction_field(name, **kwargs)

Returns the mass fraction field for the given component.

Return type:

Expression

get_mole_fraction_field(name, **kwargs)

Returns the mole fraction field for the given component.

Return type:

Expression

get_pure_component(name, raise_error=False)

Returns the pure component properties for the specified component.

Parameters:
  • name (str) – Name of the pure component.

  • raise_error (bool) – Raise an error if the component is not present in the mixture. Otherwise, None is returned.

Return type:

Optional[MaterialProperties]

Returns:

The pure properties of the component.

get_vapor_mass_concentration(component, relative_humidity_for_far_field=None, temperature=None, at_mixture_composition=True)

Calculates the saturation vapor concentration \(c_{sat}\) for the given component in [kg/m^3]. If relative_humidity_for_far_field is set, it does not apply Raoult’s law, but uses the relative humidity to calculate the vapor concentration in the far field

Parameters:
  • component (str) – Name of the component.

  • relative_humidity_for_far_field (Union[Expression, int, float, None]) – Relative humidity in the far field. If set, it is used to calculate the vapor concentration of the pure vapor in the far field.

  • temperature (Union[Expression, int, float, None]) – Temperature at which to calculate the vapor concentration. If not set, the temperature from the initial condition is used.

  • at_mixture_composition (Union[bool, Dict[str, Union[Expression, int, float]]]) – If set to True, the vapor concentration is calculated at the mixture initial composition. If set to a dictionary, the vapor concentration is calculated at the given composition.

get_vapor_pressure_for(name, pure=False)[source]

Returns the vapor pressure of a component in the mixture.

Parameters:
  • name (str) – Name of the pure component in this mixture.

  • pure (bool) – If set, it returns the vapor pressure of the pure component, i.e. in absence of all other components in this mixture.

Returns:

_description_

Return type:

ExpressionNumOrNone

make_static(cond=None, temperature=None)

This will make the mixture static, i.e. all mass fraction fields will be replaced by their values from the given condition. This is useful for to remove advection-diffusion equations if the composition stays homogeneous.

Parameters:
  • cond (Optional[Dict[str, Union[Expression, int, float]]]) – Optional condition, otherwise the initial_condition is used.

  • temperature (Union[Expression, int, float, None]) – Optional temperature

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

set_activity_coefficients_by_unifac(model, set_vapor_pressures=True, use_multi_return=3)[source]

Sets the activity coefficients by a UNIFAC model.

Parameters:
  • model (str) – A particular UNIFAC model to use. By default, pyoomph has "AIOMFAC", "Original" UNIFAC and "Dortmund" modified UNIFAC implemented.

  • set_vapor_pressures (bool) – Also set the vapor pressures using non-ideal Raoult’s law.

  • use_multi_return (Union[bool, int]) – Either a bool or a maximum number of components when to use multi-return expressions. By default, it uses multi-return for mixtures with 3 or more components. multi-return expressions are faster for code generation, but use finite differences for the Jacobian. They cannot be used in all contexts, e.g. for bifurcation tracking.

set_by_weighted_average(what=None, fraction_type='mass_fraction')

Calculate a property by just taking the weighted average of the properties of all pure components. :type what: Optional[str] :param what: Property or expression to be calculated. If None, all properties that are present in all pure components are calculated. :type fraction_type: str :param fraction_type: Which fraction to weight the average with. Can be "mass_fraction" (default) or "mole_fraction".

Raises:
  • ValueError – _description_

  • ValueError – _description_

set_diffusion_coefficient(arg1, arg2=None, arg3=None)

Set the diffusion coefficient for the specified component in the mixture.

Parameters:
  • arg1 (Union[Expression, int, float, str]) – Either the diagonal diffusion coefficient for all components or the name of the component to set the diffusion coefficient.

  • arg2 (Union[Expression, int, float, None, str]) – Either the diagonal diffusion coeffient for the component given as first argument or the name of the second component or None for off-diagonal diffusion.

  • arg3 (Union[Expression, int, float, None]) – The diffusion coefficient for off-diagonal diffusion.

set_latent_heat_of_evaporation(name, Lambda)[source]

Sets the latent heat of a single component. By default, we just use the latent heat from the pure component.

set_reference_scaling_to_problem(problem, temperature=None, **kwargs)

Set the reference scaling to nondimensionalize a dimensional problem.

Parameters:
  • problem (Problem) – The problem for which the reference scaling is being set.

  • temperature (Union[Expression, int, float, None]) – The temperature to be used for nondimensionalization. If not provided, the initial condition temperature will be used.

  • **kwargs (Union[Expression, int, float]) – Additional parameters to be used for scaling.

Raises:

RuntimeError – If at least two of the scales ‘temporal’, ‘spatial’, and ‘velocity’ are not set in the problem before.

set_vapor_pressure_by_raoults_law()[source]

Set the vapor pressures based on Raoult’s law. Potentially set activity coefficients are considered.

vapor_pressure_for: Dict[str, Union[Expression, int, float]]

A dict holding the vapor pressures given by the name of each pure component. By default, it will be set to ideal Raoult’s law.

class pyoomph.materials.generic.PureGasProperties[source]

Bases: BaseGasProperties

Provides properties of a pure gas.

diffusion_volume_for_Fuller_eq

Can be set to e.g. numerical values in (cm^3) e.g. according to, Fuller, E. N. and Giddings, J. C. 1965. J. Gas Chromatogr., 3, 222 or Fuller, E. N., Ensley, K. and Giddings, J. C. 1969. J. Phys. Chem., 75, 3679 or Fuller, E. N., Schettler, P. D. and Giddings, J. C. 1966. Ind. Eng. Chem., 58, 18

dynamic_viscosity: Union[Expression, int, float]

Dynamic viscosity of the gas

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

mass_density_from_ideal_gas_law(pressure=field(absolute_pressure, < code=0, tags=>), temperature=field(temperature, < code=0, tags=>))[source]

Returns the mass density by assuming the ideal gas law. :type pressure: Union[Expression, int, float] :param pressure: Either a constant pressure or, by default, a potentially varying pressure given by var("absolute_pressure"). :type temperature: Union[Expression, int, float] :param temperature: Either a constant temperature or, by default, a potentially varying temperature given by var("temperature").

Return type:

Expression

Returns:

The mass density according to the ideal gas law.

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

set_mass_density_from_ideal_gas_law()[source]

Sets the mass density by using mass_density_from_ideal_gas_law().

class pyoomph.materials.generic.PureLiquidProperties[source]

Bases: BaseLiquidProperties

Properties of a pure liquid.

components: Set[str] = {}

The components are used for mixtures. Here it is just the set with only the name of the liquid as only element.

default_surface_tension: Dict[Literal['gas', 'solid', 'liquid'], Union[Expression, int, float, None]]

Default surface tension of the liquid. This is a dictionary with the keys "gas", "solid", and "liquid". The value for each key is the surface tension of the liquid with the respective other phase.

dynamic_viscosity: Union[Expression, int, float]

The dynamic viscosity of the liquid.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

get_latent_heat_of_evaporation(name)[source]

Returns the latent heat of evaporation for the pure liquid.

Return type:

Union[Expression, int, float, None]

get_pure_component(name)[source]

Just returns itself if the name matches. Otherwise None.

get_vapor_mass_concentration(component, relative_humidity_for_far_field=None, temperature=None, at_mixture_composition=True)

Calculates the saturation vapor concentration \(c_{sat}\) for the given component in [kg/m^3]. If relative_humidity_for_far_field is set, it does not apply Raoult’s law, but uses the relative humidity to calculate the vapor concentration in the far field

Parameters:
  • component (str) – Name of the component.

  • relative_humidity_for_far_field (Union[Expression, int, float, None]) – Relative humidity in the far field. If set, it is used to calculate the vapor concentration of the pure vapor in the far field.

  • temperature (Union[Expression, int, float, None]) – Temperature at which to calculate the vapor concentration. If not set, the temperature from the initial condition is used.

  • at_mixture_composition (Union[bool, Dict[str, Union[Expression, int, float]]]) – If set to True, the vapor concentration is calculated at the mixture initial composition. If set to a dictionary, the vapor concentration is calculated at the given composition.

get_vapor_pressure_for(name, pure=False)[source]

Returns the vapor pressure of the pure liquid.

Return type:

Union[Expression, int, float, None]

latent_heat_of_evaporation: Union[Expression, int, float, None]

Latent heat of evaporation of the pure liquid

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

set_reference_scaling_to_problem(problem, temperature=None, **kwargs)

Set the reference scaling to nondimensionalize a dimensional problem.

Parameters:
  • problem (Problem) – The problem for which the reference scaling is being set.

  • temperature (Union[Expression, int, float, None]) – The temperature to be used for nondimensionalization. If not provided, the initial condition temperature will be used.

  • **kwargs (Union[Expression, int, float]) – Additional parameters to be used for scaling.

Raises:

RuntimeError – If at least two of the scales ‘temporal’, ‘spatial’, and ‘velocity’ are not set in the problem before.

set_unifac_groups(grps, only_for=None)[source]

Sets the UNIFAC groups for the pure liquid, which are relevant for the activity coefficients in mixtures.

Parameters:
  • grps (Dict[str, int]) – Dictionary of UNIFAC groups and their amounts.

  • only_for (Union[str, Set[str], None]) – Set groups only for specific group interaction models. Default is None, which sets the groups for the models {"AIOMFAC","Original","Dortmund"}.

set_vapor_pressure_by_Antoine_coeffs(A, B, C, convention_P=(133.32238741500000856)*second**(-2)*meter**(-1)*kilogram, convention_T=<pyoomph.expressions.units.CelsiusClass object>)[source]

Sets the vapor pressure by the Antoine equation.

Parameters:
  • A (float) – Antoine coefficient A

  • B (float) – Antoine coefficient B

  • C (float) – Antoine coefficient C

  • convention_P (Expression) – Pressure unit for the Antoine coefficients. Default is mmHg.

  • convention_T (Union[Expression, CelsiusClass]) – Temperature unit for the Antoine coefficients. Default is celsius.

vapor_pressure: Union[Expression, int, float, None]

Vapor pressure of the pure liquid

class pyoomph.materials.generic.PureSolidProperties[source]

Bases: BaseSolidProperties

Defines properties of a pure solid.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

class pyoomph.materials.generic.SurfactantProperties[source]

Bases: PureLiquidProperties

A surfactant is by definition a pure liquid property in pyoomph and can therefore be mixed with other liquids. However, it also can be adsorbed, desorbed and transported at an interface.

evaluate_at_condition(expr, cond={}, *, temperature=None, **kwargs)

Evaluates a property at the given condition (temperature, mass fractions, etc.). The mass fractions should be given as massfrac_<component_name>, where <component_name> is the name of the component. The mole fractions should be given as molefrac_<component_name>. Other typical conditions are temperature and absolute_pressure.

Parameters:
  • expr (Union[Expression, int, float, str]) – Either a property name like "mass_density" or an expression to evaluate.

  • cond (Union[Dict[str, Union[Expression, int, float]], Literal['initial', 'IC', 'initial_condition']]) – Condition to evaluate. Can be e.g. {"massfrac_water":0.5,"temperature":300*kelvin} or use the initial_condition of the material properties (shortcuts "initial", "IC" or "initial_condition").

  • temperature (Union[Expression, int, float, None]) – Temperature to evaluate the property at. If not given, the temperature from the condition will be used.

Return type:

Expression

Returns:

The property evaluated at the given condition.

get_latent_heat_of_evaporation(name)

Returns the latent heat of evaporation for the pure liquid.

Return type:

Union[Expression, int, float, None]

get_pure_component(name)

Just returns itself if the name matches. Otherwise None.

get_vapor_mass_concentration(component, relative_humidity_for_far_field=None, temperature=None, at_mixture_composition=True)

Calculates the saturation vapor concentration \(c_{sat}\) for the given component in [kg/m^3]. If relative_humidity_for_far_field is set, it does not apply Raoult’s law, but uses the relative humidity to calculate the vapor concentration in the far field

Parameters:
  • component (str) – Name of the component.

  • relative_humidity_for_far_field (Union[Expression, int, float, None]) – Relative humidity in the far field. If set, it is used to calculate the vapor concentration of the pure vapor in the far field.

  • temperature (Union[Expression, int, float, None]) – Temperature at which to calculate the vapor concentration. If not set, the temperature from the initial condition is used.

  • at_mixture_composition (Union[bool, Dict[str, Union[Expression, int, float]]]) – If set to True, the vapor concentration is calculated at the mixture initial composition. If set to a dictionary, the vapor concentration is calculated at the given composition.

get_vapor_pressure_for(name, pure=False)

Returns the vapor pressure of the pure liquid.

Return type:

Union[Expression, int, float, None]

latent_heat_of_evaporation: Union[Expression, int, float, None]

Latent heat of evaporation of the pure liquid

classmethod register(*, override=False)

Decorated your material classes with this to register them in the material library. This allows to use the functions get_pure_gas(), get_pure_liquid(), Mixture(), get_interface_properties(), etc. to retrieve the properties of the materials.

sample_all_properties_to_text_files(dirname, _sort='len', _newlines=True, **kwargs)

This function will sample all properties of this material to text files. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. The function will then sample all properties at these conditions and write them to text files in the given directory.

Parameters:
  • dirname (str) – Directory to create the text files

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

sample_property_to_text_file(fname, expr, _name=None, _sort='len', _newlines=True, **kwargs)

This function will sample a single property of this material to a text file. You can either pass single values, e.g. massfrac_water=0.5,temperature=300*kelvin, or ranges, e.g. massfrac_water=numpy.linspace(0,1,100),temperature=[300*kelvin,400*kelvin]. It will sample the property at these conditions and write them to a text file.

Parameters:
  • fname (str) – Text file name to write.

  • expr (Union[str, Expression, int, float]) – Property to sample. Can be a string with the name of the property or an expression.

  • _sort (str) – How to sort the output files. Can be "len" or "name" to sort by the length of the ranges or the names of the variables, or "len_rev" or "name_rev" to sort in reverse order.

  • _newlines (bool) – Add a new line after each set of values in the text files.

set_reference_scaling_to_problem(problem, temperature=None, **kwargs)

Set the reference scaling to nondimensionalize a dimensional problem.

Parameters:
  • problem (Problem) – The problem for which the reference scaling is being set.

  • temperature (Union[Expression, int, float, None]) – The temperature to be used for nondimensionalization. If not provided, the initial condition temperature will be used.

  • **kwargs (Union[Expression, int, float]) – Additional parameters to be used for scaling.

Raises:

RuntimeError – If at least two of the scales ‘temporal’, ‘spatial’, and ‘velocity’ are not set in the problem before.

set_unifac_groups(grps, only_for=None)

Sets the UNIFAC groups for the pure liquid, which are relevant for the activity coefficients in mixtures.

Parameters:
  • grps (Dict[str, int]) – Dictionary of UNIFAC groups and their amounts.

  • only_for (Union[str, Set[str], None]) – Set groups only for specific group interaction models. Default is None, which sets the groups for the models {"AIOMFAC","Original","Dortmund"}.

set_vapor_pressure_by_Antoine_coeffs(A, B, C, convention_P=(133.32238741500000856)*second**(-2)*meter**(-1)*kilogram, convention_T=<pyoomph.expressions.units.CelsiusClass object>)

Sets the vapor pressure by the Antoine equation.

Parameters:
  • A (float) – Antoine coefficient A

  • B (float) – Antoine coefficient B

  • C (float) – Antoine coefficient C

  • convention_P (Expression) – Pressure unit for the Antoine coefficients. Default is mmHg.

  • convention_T (Union[Expression, CelsiusClass]) – Temperature unit for the Antoine coefficients. Default is celsius.

surface_diffusivity

The default surface diffusivity of the surfactant

vapor_pressure: Union[Expression, int, float, None]

Vapor pressure of the pure liquid

pyoomph.materials.generic.get_interface_properties(phaseA, phaseB, surfactants=None)[source]

Returns the interface properties for the two given phases (and potentially surfactants at the interface) from the material library. Property classes must be decorated with the decorator MaterialProperties.register() before this works.

Parameters:
Return type:

Union[BaseInterfaceProperties, LiquidGasInterfaceProperties]

Returns:

The interface properties from the material library.

pyoomph.materials.generic.get_pure_gas(name, return_class=False)[source]

Returns the pure gas properties for the given name(s) from the material library. Property classes must be decorated with the decorator MaterialProperties.register() before this works.

Parameters:
  • name (Union[str, List[str]]) – Name of the pure gas component(s) to be returned.

  • return_class (bool) – Return the class instead of an instance of the class.

Return type:

Union[PureGasProperties, Type[PureGasProperties], Tuple[PureGasProperties, ...], Tuple[Type[PureGasProperties], ...]]

Returns:

The generated pure gas properties as object(s) or class(es).

pyoomph.materials.generic.get_pure_liquid(name, return_class=False)[source]

Returns the pure liquid properties for the given name(s) from the material library. Property classes must be decorated with the decorator MaterialProperties.register() before this works.

Parameters:
  • name (Union[str, List[str]]) – Name of the pure liquid component(s) to be returned.

  • return_class (bool) – Return the class instead of an instance of the class.

Return type:

Union[PureLiquidProperties, Type[PureLiquidProperties], Tuple[PureLiquidProperties, ...], Tuple[Type[PureLiquidProperties], ...]]

Returns:

The generated pure liquid properties as object(s) or class(es).

pyoomph.materials.generic.get_pure_solid(name, return_class=False)[source]

Returns the pure solid properties for the given name(s) from the material library. Property classes must be decorated with the decorator MaterialProperties.register() before this works.

Parameters:
  • name (Union[str, List[str]]) – Name of the pure solid component(s) to be returned.

  • return_class (bool) – Return the class instead of an instance of the class.

Return type:

Union[PureSolidProperties, Type[PureSolidProperties], Tuple[PureSolidProperties, ...], Tuple[Type[PureSolidProperties], ...]]

Returns:

The generated pure solid properties as object(s) or class(es).

pyoomph.materials.generic.get_surfactant(name, return_class=False)[source]

Returns the surfactant properties for the given name(s) from the material library. Property classes must be decorated with the decorator MaterialProperties.register() before this works.

Parameters:
  • name (Union[str, List[str]]) – Name of the surfactant properties to be returned.

  • return_class (bool) – Return the class instead of an instance of the class.

Return type:

Union[SurfactantProperties, Type[SurfactantProperties], Tuple[SurfactantProperties, ...], Tuple[Type[SurfactantProperties], ...]]

Returns:

The generated surfactant properties as object(s) or class(es).

pyoomph.materials.generic.new_pure_gas(name, mass_density=1000 * meter**-3 * kilogram, dynamic_viscosity=1 / 1000 * second**-1 * meter**-1 * kilogram, molar_mass=1 / 20 * mol**-1 * kilogram, override=False, thermal_conductivity=None, specific_heat_capacity=None)[source]

Shortcut to create new pure gas with the specified properties.

Parameters:
  • name (str) – The name of the pure gas material.

  • mass_density (Union[Expression, int, float]) – The mass density of the pure gas material.

  • dynamic_viscosity (Union[Expression, int, float]) – The dynamic viscosity of the pure gas material.

  • molar_mass (Union[Expression, int, float]) – The molar mass of the pure gas material.

  • override (bool) – Whether to override existing material properties with the same name.

  • thermal_conductivity (Union[Expression, int, float, None]) – The thermal conductivity of the pure liquid material.

  • specific_heat_capacity (Union[Expression, int, float, None]) – The specific heat capacity of the pure liquid material.

Return type:

PureGasProperties

Returns:

An instance of the new added pure gas material, which is also registered in the material library.

pyoomph.materials.generic.new_pure_liquid(name, mass_density=1000 * meter**-3 * kilogram, dynamic_viscosity=1 / 1000 * second**-1 * meter**-1 * kilogram, surface_tension=7 / 100 * second**-2 * kilogram, molar_mass=1 / 20 * mol**-1 * kilogram, override=False, thermal_conductivity=None, specific_heat_capacity=None, latent_heat=None, vapor_pressure=None)[source]

Shortcut to create new pure liquid with the specified properties.

Parameters:
  • name (str) – The name of the pure liquid material.

  • mass_density (Union[Expression, int, float]) – The mass density of the pure liquid material.

  • dynamic_viscosity (Union[Expression, int, float]) – The dynamic viscosity of the pure liquid material.

  • surface_tension (Union[Expression, int, float]) – The surface tension of the pure liquid material.

  • molar_mass (Union[Expression, int, float]) – The molar mass of the pure liquid material.

  • override (bool) – Whether to override existing material properties with the same name.

  • thermal_conductivity (Union[Expression, int, float, None]) – The thermal conductivity of the pure liquid material.

  • specific_heat_capacity (Union[Expression, int, float, None]) – The specific heat capacity of the pure liquid material.

  • latent_heat (Union[Expression, int, float, None]) – The latent heat of evaporation of the pure liquid material.

  • vapor_pressure (Union[Expression, int, float, None]) – The vapor pressure of the pure liquid material.

Return type:

PureLiquidProperties

Returns:

An instance of the new added pure liquid material, which is also registered in the material library.