RBCMHDEnv3D
- class fluidgym.envs.rbc_mhd.RBCMHDEnv3D(rayleigh_number: float, chandrasekhar_number: float, prandtl_number: float, aspect_ratio: float, resolution: int, wall_grading: float, min_layer_cells: int, n_electrodes: int, electrode_fill: float, max_current: float, power_penalty_weight: float, dt: float, adaptive_cfl: float, step_length: float, episode_length: int, aspect_ratio_x: float | None = None, n_stations: int | None = None, local_obs_window: int = 3, local_reward_weight: float | None = None, advection_scheme: str = 'linear_upwind', use_marl: bool = False, potential_tol: phipict.solvers.tolerance.SolverTolerance = None, potential_solve_max_iter: int = 10000, potential_use_preconditioner: bool = True, exclude_potential_solve_gradients: bool = False, **kwargs: Any)[source]
Bases:
FluidEnvRayleigh-Bénard convection in a horizontal magnetic field.
Each Hartmann wall is divided into
n_electrodespatches along y andn_stationsstations along z. Each patch holds a raised-cosine electrode coveringelectrode_fillof the patch pitch in y and z, surrounded by insulating wall. Electrodekexists on both walls, and the pair carries the currentI_k, half through each wall (the convention offluidgym.envs.blanket.actuators). The action setsI_k; it is centred to zero net current (the box is otherwise insulating, so the potential problem needs it), clamped to the action bounds, centred again and scaled bymax_current. In MARL mode, each station along z is an agent that sets the currents of its column of electrodes.The reward is the relative change of the volume-averaged Nusselt number minus the electrical power fed into the fluid, relative to the power the buoyancy does on the uncontrolled flow:
r = Nu / Nu_ref - 1 - power_penalty_weight * P_el / P_ref
so the heat transfer is to be raised, both averaged over the PISO steps of the env step.
Nu_refandP_refare the means of the uncontrolled episodes (domain statistics). In MARL mode, an agent receiveslocal_reward_weighttimes the same Nusselt term over the columns of its observation window plus the remainder of the global reward, as inRBCEnv3D.- Parameters:
rayleigh_number (float) – Rayleigh number based on
Hand the plate temperature difference.chandrasekhar_number (float) – Chandrasekhar number
Q = Ha^2based onH. Must be positive.prandtl_number (float) – Prandtl number.
aspect_ratio (float) – Extent of the box along z, in units of
H.aspect_ratio_x (float | None) – Extent of the box along x, i.e. along
Bbetween the Hartmann walls, in units ofH. Defaults toaspect_ratio.resolution (int) – Number of cells along y; x and z have
round(aspect_ratio_x * resolution)andround(aspect_ratio * resolution).wall_grading (float) – tanh grading strength towards the walls normal to y and z.
min_layer_cells (int) – Minimum number of cells inside the Hartmann layer at each Hartmann wall; the x grading is chosen for it.
n_electrodes (int) – Electrodes along y on each Hartmann wall.
n_stations (int | None) – Electrode stations along z. Defaults to
round(aspect_ratio * n_electrodes).electrode_fill (float) – Fraction of the patch pitch an electrode covers in y and z, in (0, 1].
max_current (float) – Largest current of an electrode pair (both walls together), in units of
sigma U B H^2.power_penalty_weight (float) – Weight of the electrical power in the reward.
dt (float) – The simulation time step; substeps adapt to
adaptive_cfl.adaptive_cfl (float) – Target CFL number for adaptive time stepping.
step_length (float) – The physical time length of each environment step.
episode_length (int) – The number of steps per episode.
local_obs_window (int) – Number of electrode stations along z an agent observes in MARL mode (odd). Beyond the side walls, the window holds the quiescent conduction state.
local_reward_weight (float | None) – Weighting factor for local rewards in multi-agent settings. Has to be set for multi-agent RL.
advection_scheme (str) – Convective scheme of the momentum equation,
"central"or"linear_upwind".use_marl (bool) – Whether to enable multi-agent reinforcement learning mode.
potential_tol (float | SolverTolerance | Mapping | None) – Tolerance of the electric potential solve.
potential_solve_max_iter (int) – Iteration limit of the electric potential solve.
potential_use_preconditioner (bool) – Whether to solve the potential with AMG-preconditioned CG.
exclude_potential_solve_gradients (bool) – Drop the gradient of the potential solve. Diagnostic only.
**kwargs – Parameters of
FluidEnv.
References
[1] T. Yanagisawa, Y. Hamano, T. Miyagoshi, Y. Yamagishi, Y. Tasaka, and Y. Takeda, “Convection patterns in a liquid metal under an imposed horizontal magnetic field,” Phys. Rev. E, vol. 88, no. 6, p. 063020, Dec. 2013, doi: 10.1103/PhysRevE.88.063020.
- compute_nusselt() Tensor[source]
Volume-averaged Nusselt number
1 + sqrt(Ra Pr) <u_y (T - T_ref)>.- Returns:
The Nusselt number of every environment,
[E].- Return type:
- get_temperature() Tensor[source]
Return the current temperature field resampled to the render shape.
- Returns:
Temperature field, with a leading env dim for a vectorized environment.
- Return type:
- property initial_domain_id: str
Unique identifier for the initial domain.
The uncontrolled flow is the same for every electrode layout, and the electrode conditions are applied after loading (see
_apply_potential_layout()), so all of them share the domains of the plain insulating box.
- property obs_resampling_shape: tuple[int, ...]
The shape
(x, y, z)of the observation resampling grid.