mpet package

Subpackages

Submodules

mpet.daeVariableTypes module

This module defines custom daetools variable types

mpet.data_reporting module

Helper functions/classes for outputting data generated by the simulation.

class mpet.data_reporting.Myhdf5DataReporterFast(*args: Any, **kwargs: Any)[source]

Bases: daeMatlabMATFileDataReporter

Ignores internal particle concentrations with hdf5 data saving to be faster. Input is dataReporter

WriteDataToFile()[source]
class mpet.data_reporting.Myhdf5DataReporter(*args: Any, **kwargs: Any)[source]

Bases: daeMatlabMATFileDataReporter

Reports hdf5 file outputs in full, otherwise ignores internal particle concentrations

WriteDataToFile()[source]
class mpet.data_reporting.MyMATDataReporter(*args: Any, **kwargs: Any)[source]

Bases: daeMatlabMATFileDataReporter

See source code for pyDataReporting.daeMatlabMATFileDataReporter Takes in dataReporter

WriteDataToFile()[source]
mpet.data_reporting.setup_data_reporters(simulation, config, outdir)[source]

Create daeDelegateDataReporter and add data reporter.

mpet.exceptions module

exception mpet.exceptions.UnknownParameterError[source]

Bases: Exception

mpet.extern_funcs module

Functions used in the simulation which cannot be represented by simple analytical functions.

These functions are handled here because they cannot be written in a form that DAE Tools knows how to automatically differentiate. For example, they may contain if statements or a function from an external library that the DAE Tools library doesn’t know about.

class mpet.extern_funcs.InterpTimeScalar(*args: Any, **kwargs: Any)[source]

Bases: daeScalarExternalFunction

Calculate(values)[source]

mpet.geometry module

Helper functions to get information about the mesh/geometry of the simulated particles.

mpet.geometry.get_unit_solid_discr(Shape, N)[source]
mpet.geometry.get_dr_edges(shape, N)[source]
mpet.geometry.calc_curv(c, dr, r_vec, Rs, beta_s, particleShape)[source]
mpet.geometry.get_elyte_disc(Nvol, L, poros, BruggExp)[source]
mpet.geometry.get_interface_disc(Nvol, L, poros, BruggExp)[source]

mpet.main module

mpet.mod_CCCVCPcycle module

Added module for cycling segments

class mpet.mod_CCCVCPcycle.CCCVCPcycle(*args: Any, **kwargs: Any)[source]

Bases: daeModel

DeclareEquations()[source]

mpet.mod_cell module

mpet.mod_electrodes module

These models define individual particles of active material.

This includes the equations for both 1-parameter models and 2-parameters models defining
  • mass conservation (concentration evolution)

  • reaction rate at the surface of the particles

In each model class it has options for different types of particles:
  • homogeneous

  • Fick-like diffusion

  • Cahn-Hilliard (with reaction boundary condition)

  • Allen-Cahn (with reaction throughout the particle)

These models can be instantiated from the mod_cell module to simulate various types of active materials within a battery electrode.

class mpet.mod_electrodes.Mod2var(*args: Any, **kwargs: Any)[source]

Bases: daeModel

get_trode_param(item)[source]

Shorthand to retrieve electrode-specific value

DeclareEquations()[source]
sld_dynamics_0D2var(c1, c2, muO, act_lyte, noises)[source]
sld_dynamics_1D2var(c1, c2, muO, act_lyte, noises)[source]
class mpet.mod_electrodes.Mod1var(*args: Any, **kwargs: Any)[source]

Bases: daeModel

get_trode_param(item)[source]

Shorthand to retrieve electrode-specific value

DeclareEquations()[source]
sld_dynamics_0D1var(c, muO, act_lyte, noise)[source]
sld_dynamics_1D1var(c, muO, act_lyte, noise)[source]
mpet.mod_electrodes.calc_surf_diff(c_surf, muR_surf, D)[source]
mpet.mod_electrodes.calc_eta(muR, muO)[source]
mpet.mod_electrodes.get_Mmat(shape, N)[source]
mpet.mod_electrodes.calc_flux_diffn(c, D, Dfunc, E_D, Flux_bc, dr, T, noise)[source]
mpet.mod_electrodes.calc_flux_CHR(c, mu, D, Dfunc, E_D, Flux_bc, dr, T, noise)[source]
mpet.mod_electrodes.calc_flux_CHR2(c1, c2, mu1_R, mu2_R, D, Dfunc, E_D, Flux1_bc, Flux2_bc, dr, T, noise1, noise2)[source]
mpet.mod_electrodes.calc_mu_O(c_lyte, phi_lyte, phi_sld, T, config, trode)[source]
mpet.mod_electrodes.calc_muR(c, cbar, config, trode, ind)[source]
mpet.mod_electrodes.MX(mat, objvec)[source]

mpet.mod_interface module

class mpet.mod_interface.InterfaceRegion(*args: Any, **kwargs: Any)[source]

Bases: daeModel

DeclareEquations()[source]
mpet.mod_interface.get_interface_internal_fluxes(c, phi, disc, config)[source]

mpet.ports module

This defines the ports by which mod_cell interacts with mod_electrodes.

class mpet.ports.portFromElyte(*args: Any, **kwargs: Any)[source]

Bases: daePort

class mpet.ports.portFromBulk(*args: Any, **kwargs: Any)[source]

Bases: daePort

class mpet.ports.portFromParticle(*args: Any, **kwargs: Any)[source]

Bases: daePort

class mpet.ports.portFromInterface(*args: Any, **kwargs: Any)[source]

Bases: daePort

mpet.props_am module

This module handles properties associated with the active materials. Only helper functions are defined here. Diffusion functions are defined in mpet.electrode.diffusion Chemical potential functions are defined in mpet.electrode.materials

class mpet.props_am.muRfuncs(config, trode, ind=None)[source]

Bases: object

config is the full dictionary of parameters for the electrode particles, as made for the simulations. trode is the selected electrode. ind is optinally the selected particle, provided as (vInd, pInd)

get_trode_param(item)[source]

Shorthand to retrieve electrode-specific value

get_muR_from_OCV(OCV, muR_ref)[source]
ideal_sln(y)[source]

Helper function: Should not be called directly from simulation. Call a specific material instead.

reg_sln(y, Omga)[source]

Helper function

graphite_2param_homog(y, Omga, Omgb, Omgc, EvdW)[source]

Helper function

graphite_1param_homog(y, Omga, Omgb)[source]

Helper function

graphite_1param_homog_2(y, Omga, Omgb)[source]

Helper function

graphite_1param_homog_3(y, Omga, Omgb)[source]

Helper function with low hysteresis and soft tail

non_homog_rect_fixed_csurf(y, ybar, B, kappa, ywet)[source]

Helper function

non_homog_rect_variational(y, ybar, B, kappa)[source]

Helper function

non_homog_round_wetting(y, ybar, B, kappa, beta_s, shape, r_vec)[source]

Helper function

general_non_homog(y, ybar)[source]

Helper function

mpet.props_am.step_down(x, xc, delta)[source]
mpet.props_am.step_up(x, xc, delta)[source]

mpet.sim module

mpet.utils module

mpet.utils.mean_linear(a)[source]

Calculate the linear mean along a vector.

mpet.utils.weighted_linear_mean(a, wt)[source]
mpet.utils.mean_harmonic(a)[source]

Calculate the harmonic mean along a vector.

mpet.utils.weighted_harmonic_mean(a, wt)[source]
mpet.utils.add_gp_to_vec(vec)[source]

Add ghost points to the beginning and end of a vector for applying boundary conditions.

mpet.utils.pad_vec(vec)[source]

Repeat a vector’s first and last values, extending its length by two.

mpet.utils.get_const_vec(val, N)[source]

Convert a constant to an array of length N.

mpet.utils.get_var_vec(var, N, dt=False)[source]

Convert a dae tools variable to a numpy array. Optionally return the time derivative of the variable.

mpet.utils.get_asc_vec(var, Nvol, dt=False)[source]

Get a numpy array for a variable spanning the anode, separator, and cathode.

mpet.utils.get_dxvec(L, Nvol)[source]

Get a vector of cell widths spanning the full cell.

mpet.utils.get_git_info(local_dir, shell=False)[source]
mpet.utils.open_data_file(dataFile)[source]

Load hdf5/mat file output. Always defaults to .mat file, else opens .hdf5 file. Takes in dataFile (path of file without .mat or .hdf5), returns data (output of array)

mpet.utils.get_dict_key(data, string, squeeze=True, final=False)[source]

Gets the values in a 1D array, which is formatted slightly differently depending on whether it is a h5py file or a mat file Takes in data array and the string whose value we want to get. Final is a boolean that determines whether or not it only returns the final value of the array. If final is true, then it only returns the last value, otherwise it returns the entire array. Final overwrites squeeze–if final is true, then the array will always be squeezed. Squeeze squeezes into 1D array if is true, otherwise false

mpet.utils.get_negative_sign_change_arrays(input_array)[source]

This function takes an array of (+1, +1, +1, -1, -1, -1… +1, -1 …) and splits it into a number of arrays in the y direction which are (0, 0, 0, 1, 1, 1… 0, 0) whenever the array hits a sign change. It should have the number of cycles as rows. Thus it will be size (N*M) for each output, where N is the number of cycles and M is the size of the array. In each ith row there are only 1’s for the ith charging cycle. Returns beginning and end discharge and charge segments in order

mpet.utils.import_function(filename, function, mpet_module=None)[source]

Load a function from a file that is not part of MPET, with a fallback to MPET internal functions.

Parameters:
  • config (Config) – MPET configuration

  • filename (str) – .py file containing the function to import. None to load from mpet_module instead

  • function (str) – Name of the function to import

  • mpet_module (str) – MPET module to import function from if no filename is set (optional)

Returns:

A callable function

mpet.version module

Module contents