bmlite.mesh#
The mesh module has functions to build pointers and meshes. Pointers are
the integer indices for state variables. State variables in a model may be
defined in different dimensions. For example, phi_ed is 0D in the single
particle model and Li_ed is 1D in the r direction. Therefore, within
any given model, it may be useful to have a combination of ptr for 0D,
x_ptr for 1D in x, xr_ptr for 2D in x and r, etc.
This module also contains functions to build meshes. In finite volume methods, the mesh specifies the locations of the control volume centers as well as the interfaces between two control volumes. It makes sense to store both pointers and mesh functions in the same module because the pointers must be self consistent for any given model.
Functions#
|
Determine relative parameter weights between adjacent control volumes. |
|
Add an |
|
Determine the interface and center locations for uniformly meshed control |
|
Add an |
|
Add an |
Module Contents#
- bmlite.mesh.param_weights(xm, xp)[source]#
Determine relative parameter weights between adjacent control volumes.
In finite volume method solutions, fluxes are calculated at the boundaries between control volumes. Therefore, locally resolved parameters must be weighted between the adjacent volumes participating in the calculation. This function calculates those weights.
- Parameters:
xm (1D array) – Locations of the “minus” interfaces in the mesh.
xp (1D array) – Locations of the “plus” interfaces in the mesh.
- Returns:
wt_m (1D array) – Parameter weights for each of the “minus” half volumes.
wt_p (1D array) – Parameter weights for each of the “plus” half volumes.
- bmlite.mesh.r_ptr(domain, keys)[source]#
Add an
rpointer dictionary to the domain object.An
rpointer is a dictionary where the keys are variables and the values are 1Dintarrays that specify the solution vector indices for all of the specified variable’s values in therdirection. Using this pointer removes for loops from the model DAEs and makes it easier to vectorize expressions.- Parameters:
domain (domain object) – A domain (anode, separator, cathode, etc.) object from one of the model domain modules. The domain should already have
ptrandNrattributes. Theptrattribute is a dictionary where the keys are variable names and the values are the indices for the first occurrence of that variable.Nris the number ofrcontrol volumes.keys (list[str]) – A list of the variable names defined in the
rdirection. This list should be a subset of the domain’s existingptrkeys.
- bmlite.mesh.uniform_mesh(Lx, Nx, x0=0.0)[source]#
Determine the interface and center locations for uniformly meshed control volumes.
- Parameters:
Lx (float) – The length of the domain to mesh.
Nx (int) – Number of control volumes that span the domain’s length.
x0 (int, optional) – The reference value for the start of the domain’s mesh. The default is 0.
- Returns:
xm (1D array) – The “minus” interface locations. Note that
xm[0] = x0.xp (1D array) – The “plus” interface locations. Note that
xp[0] = x0 + Lx.x (1D array) – The locations of the control volume centers.
xm[i] < x[i] < xp[i]for all control volumesi.
Notes
Although the inputs and outputs are labeled using
xas the variable, this mesh is equally valid for other directions (e.g., radial).
- bmlite.mesh.x_ptr(domain, keys)[source]#
Add an
xpointer dictionary to the domain object.An
xpointer is a dictionary where the keys are variables and the values are 1Dintarrays that specify the solution vector indices for all of the specified variable’s values in thexdirection. Using this pointer removes for loops from the model DAEs and makes it easier to vectorize expressions.- Parameters:
domain (domain object) – A domain (anode, separator, cathode, etc.) object from one of the model domain modules. The domain should already have
ptrandNxattributes. Theptrattribute is a dictionary where the keys are variable names and the values are the indices for the first occurrence of that variable.Nxis the number ofxcontrol volumes.keys (list[str]) – A list of the variable names defined in the
xdirection. This list should be a subset of the domain’s existingptrkeys.
- bmlite.mesh.xr_ptr(domain, keys)[source]#
Add an
xrpointer dictionary to the domain object.An
xrpointer is a dictionary where the keys are variables and the values are 2Dintarrays that specify the solution vector indices for all of the specified variable’s values in thex(rows) andr(cols) directions. Using this pointer removes for loops from the model DAEs and makes it easier to vectorize expressions.- Parameters:
domain (domain object) – A domain (anode, separator, cathode, etc.) object from one of the model domain modules. The domain should already have
ptr,Nx, andNrattributes. Theptrattribute is a dictionary where the keys are variable names and the values are the indices for the first occurrence of that variable.NxandNrare the number ofxandrcontrol volumes, respectively.keys (list[str]) – A list of the variable names defined in both the
xandrdirections. This list should be a subset of the domain’s existingptrkeys.