FEMSimulation

class nrv.fmod.FEM.fenics_utils.FEMSimulation(D=3, mesh_file='', mesh=None, data=None, elem=None, ummesh=True, comm=<MagicMock name='mock.MPI.COMM_SELF' id='139958332359888'>, rank=0)[source]

Class usefull to solve the Static/Quasi-Static electrical current problem using FEM with FEniCSx algorithms (https://fenicsproject.org).

\[\nabla \mathbf{j}(\mathbf{r}) = 0\]
\[\mathbf{j}(\mathbf{r}) = \mathbf{\sigma} (\mathbf{r}) \nabla V (\mathbf{r}), \forall \mathbf{r} \in \Omega\]

Where \(\Omega\) is the simulation space, \(\bf{j}\) the the current density and \(V\) the electrical potential

The problem parameters (domains and boundaries condition) can be define using FEMParameters methods Contains methods to setup the matrix sytstem, to solve it and to access the results.

Parameters:
  • D (int) – dim of the mesh, by default 3 NB: only 3 is implemented

  • mesh_file (str) – mesh directory and file name: by default “”

  • mesh (None or MshCreator) – if not None, (MshCreator) from which the mesh sould be used, by default None

  • data (str, dict or FEMParameters) – if not None, load FEMParameters attribute from data, by default None

  • elem (tupple (str, int)) – if None, (“Lagrange”, 1), else (element type, element order), by default None

  • ummesh (bool) – if True the scale of mesh space dimensions should be (um), else (m), by default True Usefull to link the update materials conductivity as in NRV conductivities are in S/m but NerveMshCreator space scale is um)

  • comm (int) – The MPI communicator to use for mesh creation, by default MPI.COMM_SELF

  • rank (int) – The rank the Gmsh model is initialized on, by default 0

Methods

FEMSimulation.__init__([D, mesh_file, mesh, ...])

initialisation of the FEMSimulation

FEMSimulation.add_boundary(mesh_domain, btype)

add new boundary or update if mesh_domain already exists

FEMSimulation.add_domain(mesh_domain[, ...])

add new domain or update if mesh_domain already exists

FEMSimulation.add_inboundary(mesh_domain, ...)

add new internal boundary or update if mesh_domain already exists

FEMSimulation.compute_conductance([order])

FEMSimulation.get_domain_potential(dom_id[, ...])

FEMSimulation.get_mixedspace_domain([...])

TO DO

FEMSimulation.get_mixedspace_mat_pty([...])

TO DO

FEMSimulation.get_parameters()

Generic method returning all the atributes of an NRV_class instance

FEMSimulation.get_solver_opt()

get krylov solver options

FEMSimulation.get_space_of_domain(i_domain)

TO DO

FEMSimulation.get_spaces_of_ibound(i_ibound)

retrun the surounding spaces of an internal boundary.

FEMSimulation.get_surface(dom_id)

FEMSimulation.get_timers()

FEMSimulation.load(data)

Load all FEMParameters properties from a dictionary or a json file

FEMSimulation.load_SimParameters([data])

FEMSimulation.print_mixedspace_domain()

FEMSimulation.print_mixedspace_mat_pty()

FEMSimulation.save([save, fname])

Return FEMParameters as dictionary and eventually save it as json file

FEMSimulation.save_SimParameters([save, fname])

FEMSimulation.set_mesh_file(new_mesh_file)

set a new mesh file name

FEMSimulation.set_parameters(**kawrgs)

Generic method to set any attribute of NRV_class instance

FEMSimulation.set_result_merging([to_merge])

FEMSimulation.set_solver_opt([ksp_type, ...])

set krylov solver options

FEMSimulation.setup_sim(**kwargs)

setup Bilinear form, Linear form and boundary conditions using paramters and kwargs to set the variable defined Neumann boundary conditions (see FEMParameters.add_boundary) If FEMSimulation already defined, can be used to modify variable defined NBC

FEMSimulation.solve([overwrite])

Assemble and solve the linear problem

FEMSimulation.solve_and_save_sim(filename[, ...])

FEMSimulation.solver_info([txt_fname])

FEMSimulation.visualize_mesh()