jf1uids.fluid_equations.fluid module#

jf1uids.fluid_equations.fluid.conserved_state_from_primitive(primitive_state: Float[Array, 'num_vars num_cells_x'] | Float[Array, 'num_vars num_cells_x num_cells_y'] | Float[Array, 'num_vars num_cells_x num_cells_y num_cells_z'], gamma: float | Float[Array, ''], config: SimulationConfig, registered_variables: RegisteredVariables) Float[Array, 'num_vars num_cells_x'] | Float[Array, 'num_vars num_cells_x num_cells_y'] | Float[Array, 'num_vars num_cells_x num_cells_y num_cells_z'][source]#

Convert the primitive state to the conserved state.

Parameters:
  • primitive_state – The primitive state.

  • gamma – The adiabatic index of the fluid.

Returns:

The conserved state.

jf1uids.fluid_equations.fluid.construct_primitive_state(config: SimulationConfig, registered_variables: RegisteredVariables, density: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'], velocity_x: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'] | None = None, velocity_y: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'] | None = None, velocity_z: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'] | None = None, magnetic_field_x: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'] | None = None, magnetic_field_y: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'] | None = None, magnetic_field_z: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'] | None = None, gas_pressure: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'] | None = None, cosmic_ray_pressure: Float[Array, 'num_cells_x'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'] | None = None) Float[Array, 'num_vars num_cells_x'] | Float[Array, 'num_vars num_cells_x num_cells_y'] | Float[Array, 'num_vars num_cells_x num_cells_y num_cells_z'][source]#

Stack the primitive variables into the state array.

IN 1D SET ONLY THE XCOMPONENTS, in 2D SET X AND Y COMPONENTS, in 3D SET X, Y AND Z COMPONENTS

Parameters:
  • rho – The density of the fluid.

  • u – The velocity of the fluid.

  • p – The pressure of the fluid.

  • registered_variables – The indices of the variables in the state array.

Returns:

The state array.

jf1uids.fluid_equations.fluid.construct_primitive_state3D(rho: Float[Array, 'num_cells num_cells num_cells'], u_x: Float[Array, 'num_cells num_cells num_cells'], u_y: Float[Array, 'num_cells num_cells num_cells'], u_z: Float[Array, 'num_cells num_cells num_cells'], p: Float[Array, 'num_cells num_cells num_cells'], registered_variables: RegisteredVariables) Float[Array, 'num_vars num_cells num_cells num_cells'][source]#

Stack the primitive variables into the state array.

Parameters:
  • rho – The density of the fluid.

  • u – The velocity of the fluid.

  • p – The pressure of the fluid.

  • registered_variables – The indices of the variables in the state array.

Returns:

The state array.

jf1uids.fluid_equations.fluid.get_absolute_velocity(primitive_state: Float[Array, 'num_vars num_cells_x'] | Float[Array, 'num_vars num_cells_x num_cells_y'] | Float[Array, 'num_vars num_cells_x num_cells_y num_cells_z'], config: SimulationConfig, registered_variables: RegisteredVariables) Float[Array, 'num_cells'] | Float[Array, 'num_cells_x num_cells_y'] | Float[Array, 'num_cells_x num_cells_y num_cells_z'][source]#

Get the absolute velocity of the fluid.

Parameters:
  • primitive_state – The primitive state of the fluid.

  • config – The simulation configuration.

  • registered_variables – The registered variables.

Returns:

The absolute velocity.

jf1uids.fluid_equations.fluid.internal_energy_from_energy(E, rho, u)[source]#

Calculate the internal energy from the total energy.

Parameters:
  • E – The total energy.

  • rho – The density.

  • u – The velocity.

Returns:

The internal energy.

jf1uids.fluid_equations.fluid.pressure_from_energy(E, rho, u, gamma)[source]#

Calculate the pressure from the total energy.

Parameters:
  • E – The total energy.

  • rho – The density.

  • u – The velocity.

  • gamma – The adiabatic index.

Returns:

The pressure.

jf1uids.fluid_equations.fluid.pressure_from_internal_energy(e, rho, gamma)[source]#

Calculate the pressure from the internal energy.

Parameters:
  • e – The internal energy.

  • rho – The density.

  • gamma – The adiabatic index.

Returns:

The pressure.

jf1uids.fluid_equations.fluid.primitive_state_from_conserved(conserved_state: Float[Array, 'num_vars num_cells_x'] | Float[Array, 'num_vars num_cells_x num_cells_y'] | Float[Array, 'num_vars num_cells_x num_cells_y num_cells_z'], gamma: float | Float[Array, ''], config: SimulationConfig, registered_variables: RegisteredVariables) Float[Array, 'num_vars num_cells_x'] | Float[Array, 'num_vars num_cells_x num_cells_y'] | Float[Array, 'num_vars num_cells_x num_cells_y num_cells_z'][source]#

Convert the conserved state to the primitive state.

Parameters:
  • conserved_state – The conserved state.

  • gamma – The adiabatic index of the fluid.

Returns:

The primitive state.

jf1uids.fluid_equations.fluid.speed_of_sound(rho, p, gamma)[source]#

Calculate the speed of sound.

Parameters:
  • rho – The density.

  • p – The pressure.

  • gamma – The adiabatic index.

Returns:

The speed of sound.

jf1uids.fluid_equations.fluid.total_energy_from_primitives(rho, u, p, gamma)[source]#

Calculate the total energy from the primitive variables.

Parameters:
  • rho – The density.

  • u – The velocity.

  • p – The pressure.

  • gamma – The adiabatic index.

Returns:

The total energy.