jaxfluids.forcing package
Submodules
jaxfluids.forcing.forcing module
- class jaxfluids.forcing.forcing.Forcing(domain_information: DomainInformation, material_manager: MaterialManager, unit_handler: UnitHandler, levelset_handler: LevelsetHandler | None, levelset_type: str, is_mass_flow_forcing: bool, is_temperature_forcing: bool, is_turb_hit_forcing: bool, mass_flow_target: float | function, flow_direction: str, temperature_target: float | function)[source]
Bases:
objectClass that manages the computation of external forcing terms.
Currently implemented are: 1) Mass flow rate forcing 2) Temperature forcing 3) Homogeneous isotropic turbulence forcing
- calculate_velocity_forcing_vector(vels: Array, vels_dash: Array, eta_s: int, timestep: float) Array[source]
Calculates the velocity forcing vector for HIT forcing.
- Parameters:
- Returns:
Buffer of the velocity forcing vector.
- Return type:
jnp.ndarray
- compute_forcings(primes: Array, cons: Array, levelset: Array | None, volume_fraction: Array | None, current_time: float, timestep_size: float, PID_e_new: float, PID_e_int: float, logger: Logger, primes_dash: Array | None = None, **kwargs) Dict[source]
Computes forcings for temperature, mass flow and turbulence kinetic energy.
- Parameters:
primes (jnp.ndarray) – buffer of primitive variables
primes_dash (Union[jnp.ndarray, None]) – buffer of primitive variables for next time step without forcing
cons (jnp.ndarray) – buffer of conservative variables
volume_fraction (Union[jnp.ndarray, None]) – buffer of volume fractions
mask_real (Union[jnp.ndarray, None]) – mask indicating the real fluid
current_time (float) – current physical simulation time
timestep_size (float) – current physical time step size
PID_e_new (float) – Error of previous timestep for PID controller
PID_e_int (float) – Accumalated error for PID controller
logger (Logger) – Logger for terminal output
- Returns:
Dictionary containing buffers of forcings
- Return type:
Dict
- compute_mass_flow_forcing(cons: Array, primes: Array, volume_fraction: Array | None, current_time: float, timestep_size: float, PID_e_new: float, PID_e_int: float) Tuple[Array, float, float, float, float][source]
Computes mass flow forcing
- Parameters:
cons (jnp.ndarray) – Buffer of the conservative variables.
primes (jnp.ndarray) – Buffer of the primitive variables.
volume_fraction (Union[jnp.ndarray, None]) – Buffer of the volume fraction in two-phase flows.
current_time (float) – Current simulation time.
timestep_size (float) – Current time step.
PID_e_new (float) – Current PID error
PID_e_int (float) – Current PID integral error
- Returns:
Buffer of the body force, current mass flow, mass flow target, PID error, PID integral error
- Return type:
- compute_temperature_forcing(primes: Array, levelset: Array | None, volume_fraction: Array | None, current_time: float, timestep_size: float) Tuple[Array, float][source]
Computes temperature forcing.
- Parameters:
- Returns:
Buffer of the forcing vector and the mean absolute error wrt the temperature target.
- Return type:
Tuple[jnp.ndarray, float]
- compute_turb_hit_forcing(primes: Array, primes_dash: Array, timestep: float) Array[source]
Computes forcing for HIT
- Parameters:
primes (jnp.ndarray) – Buffer of primitive variables.
primes_dash (jnp.ndarray) – Buffer of intermediate primitive variables which are obtained by integrating primes without forcing term.
timestep (float) – Current time step.
- Returns:
Buffer of the forcing vector.
- Return type:
jnp.ndarray
jaxfluids.forcing.pid_control module
- class jaxfluids.forcing.pid_control.PIDControl(K_static: float = 1.0, K_P: float = 1.0, K_I: float = 1.0, K_D: float = 0.0, T_N: float = 0.5, T_V: float = 0.5)[source]
Bases:
objectStandard PID controller. Used for example in the computation of the mass flow forcing in channel flows.
u = K_s * (K_p * e + K_i * e_int + K_d de/dt)
- compute_output(current_value: float, target_value: float, dt: float, e_old: float, e_int: float) Tuple[float, float, float][source]
Computes the control variable based on a standard PID controller.
- Parameters:
- Returns:
Updated control variable, updated instantaneous and integral errors
- Return type: