fourier#
- matinverse.fourier.Fourier(geo, boundary_conditions, thermal_conductivity=None, heat_capacity=None, conductance=None, heat_source=None, mode='linear', linear_solver='iterative', collapse_direct=False, compute_side_flux=None, batch_size=1, tol=1e-09, maxiter=5000, maxiter_nonlinear=100, scale_nonlinear=None, maxiter_transient=10000, saveat=None, DT=1.0, NT=1, X0=None)#
Differentiable Fourier solver based on the Finite-volume method.
- Parameters:
geo (
Union
[Geometry2D
,Geometry3D
]) – The geometry object containing the mesh information.boundary_conditions (
BoundaryConditions
) – The boundary conditions objectthermal_conductivity (
Optional
[Callable
]) –A function that takes batch, space (as a function of volume index), temperature and time and returns the thermal conductivity tensor \([\mathrm{W\,m^{-1}\,K^{-1}}]\)
Example:
thermal_conductivity = lambda batch, space, temp, t: 100.*jnp.eye(geo.dim)
heat_capacity (
Optional
[Callable
]) –A function that takes batch, space (as a function of volume index), temperature and time and returns the heat capacity \([\mathrm{J\,m^{-3}\,K^{-1}}]\). Example:
heat_capacity = lambda batch, space, temp, t: 1e3
conductance (
Optional
[Callable
]) –A function that takes the indices of the volumes adjacent to a given side and returns the batched conductance \([\mathrm{W\,m^{-2}\,K^{-1}}]\). If not provided, it is assumed to be large number so it won’t affect calculation.
- Example::
conductance = lambda s1,s2: 1e3*jnp.ones(1) #assuming a single batch and uniform conductance
heat_source (
Optional
[Callable
]) –A function that takes batch, space (as a function of volume index) and time and returns the heat source \([\mathrm{W\,m^{-3}}]\). If not provided, it is assumed to be zero.
- Example::
heat_source = lambda b,s,t: 1e5
mode (
str
) – The mode of the solver. Can be ‘linear’, ‘nonlinear’ or ‘transient’.linear_solver (
str
) – The linear solver to use. Can be ‘iterative’ or ‘direct’. If ‘iterative’, it uses the GMRES method. If ‘direct’, it uses sparse LU factorization.collapse_direct (
bool
) – IfTrue
, it uses the same assembly matrix for all the batches in the direct solver. It can be used only for direct solvers and if no Robin BCs are used.compute_side_flux (
array
) – A jnp.array containing the indices of the sides for which the flux will be computed. If not provided, no internal interfacial flux will be computed.batch_size (
int
) – The number of batches to use. If > 1, the solver will be vectorized over the batches.tol (
float
) – The tolerance for the linear solver.maxiter (
int
) – The maximum number of iterations for the solver.maxiter_nonlinear (
int
) – The maximum number of iterations for the nonlinear solver (default is 100). It is used only ifmode='nonlinear'
.scale_nonlinear (
float
) – A scaling factor for the nonlinear solver. If not provided, it is set to \(10^{-4} dx^2\) It is used only ifmode='nonlinear'
.maxiter_transient (
int
) – The maximum number of iterations for the transient solver (default is 10000). It is used only ifmode='transient'
.saveat (
array
) – A jnp.array containing the time steps at which the solution will be saved. If not provided, it saves all time steps.DT (
float
) – The time step for the transient solver.NT (
int
) – The number of time steps for the transient solver.X0 (
array
) – The initial guess for the temperature. It is expected to be of shape(batch_size, geo.nDOFs)
. Ifbatch_size = 1
then it can be a 1D array. If not provided, it is assumed to be zero.
- Returns:
(
dict
,dict
) – A tuple containing the output dictionary and the statistics dictionary. The output dictionary contains the following fields:
‘T’: The temperature field of shape
(NT, batch_size, geo.nDOFs)
.‘J’: The heat flux field of shape
(NT, batch_size, geo.nDOFs, geo.dim)
.‘kappa’: The thermal conductivity tensor field of shape
(NT, batch_size, geo.nDOFs, geo.dim, geo.dim)
.‘kappa_effective’: The effective thermal conductivity field of shape
(NT, batch_size, geo.nDOFs)
.‘P_boundary’: The boundary flux field of shape
(NT, batch_size, geo.nBoundarySides)
.‘P_internal’: The internal flux field of shape
(NT, batch_size, geo.nSides)
.‘T_boundary’: The temperature field at the boundaries of shape
(NT, batch_size, geo.nBoundarySides)
.
The statistics dictionary contains the following fields:
‘num_steps’: The number of steps taken by the nonlinear solver.