forked from pybamm-team/PyBaMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
232 lines (207 loc) · 6.65 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#
# Root of the pybamm module.
# Provides access to all shared functionality (models, solvers, etc.).
#
# The code in this file is adapted from Pints
# (see https://github.com/pints-team/pints)
#
import sys
import os
#
# Version info
#
def _load_version_int():
try:
root = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(root, "version"), "r") as f:
version = f.read().strip().split(",")
major, minor, revision = [int(x) for x in version]
return major, minor, revision
except Exception as e:
raise RuntimeError("Unable to read version number (" + str(e) + ").")
__version_int__ = _load_version_int()
__version__ = ".".join([str(x) for x in __version_int__])
if sys.version_info[0] < 3:
del x # Before Python3, list comprehension iterators leaked
#
# Expose PyBaMM version
#
def version(formatted=False):
"""
Returns the version number, as a 3-part integer (major, minor, revision).
If ``formatted=True``, it returns a string formatted version (for example
"PyBaMM 1.0.0").
"""
if formatted:
return "PyBaMM " + __version__
else:
return __version_int__
#
# Constants
#
# Float format: a float can be converted to a 17 digit decimal and back without
# loss of information
FLOAT_FORMAT = "{: .17e}"
# Absolute path to the PyBaMM repo
script_path = os.path.abspath(__file__)
ABSOLUTE_PATH = os.path.join(os.path.split(script_path)[0], "..")
#
# Utility classes and methods
#
from .util import Timer, FuzzyDict
from .util import root_dir, load_function, rmse, get_infinite_nested_dict, load
from .util import get_parameters_filepath
from .logger import logger, set_logging_level
from .settings import settings
from .citations import Citations, citations, print_citations
#
# Classes for the Expression Tree
#
from .expression_tree.symbol import *
from .expression_tree.binary_operators import *
from .expression_tree.concatenations import *
from .expression_tree.array import Array
from .expression_tree.matrix import Matrix
from .expression_tree.unary_operators import *
from .expression_tree.functions import *
from .expression_tree.interpolant import Interpolant
from .expression_tree.input_parameter import InputParameter
from .expression_tree.parameter import Parameter, FunctionParameter
from .expression_tree.broadcasts import *
from .expression_tree.scalar import Scalar
from .expression_tree.variable import Variable, ExternalVariable, VariableDot
from .expression_tree.variable import VariableBase
from .expression_tree.independent_variable import *
from .expression_tree.independent_variable import t
from .expression_tree.vector import Vector
from .expression_tree.state_vector import StateVectorBase, StateVector, StateVectorDot
from .expression_tree.exceptions import *
# Operations
from .expression_tree.operations.simplify import (
Simplification,
simplify_if_constant,
simplify_addition_subtraction,
simplify_multiplication_division,
)
from .expression_tree.operations.evaluate import (
find_symbols,
id_to_python_variable,
to_python,
EvaluatorPython,
)
from .expression_tree.operations.jacobian import Jacobian
from .expression_tree.operations.convert_to_casadi import CasadiConverter
from .expression_tree.operations.unpack_symbols import SymbolUnpacker
#
# Model classes
#
from .models.base_model import BaseModel
from .models import standard_variables
from .models.event import Event
from .models.event import EventType
# Battery models
from .models.full_battery_models.base_battery_model import BaseBatteryModel
from .models.full_battery_models import lead_acid
from .models.full_battery_models import lithium_ion
#
# Submodel classes
#
from .models.submodels.base_submodel import BaseSubModel
from .models.submodels import (
convection,
current_collector,
electrolyte_conductivity,
electrolyte_diffusion,
electrode,
external_circuit,
interface,
oxygen_diffusion,
particle,
porosity,
thermal,
tortuosity,
)
#
# Geometry
#
from .geometry.geometry import (
Geometry,
Geometry1DMacro,
Geometry3DMacro,
Geometry1DMicro,
Geometry1p1DMicro,
Geometryxp1DMacro,
Geometryxp0p1DMicro,
Geometryxp1p1DMicro,
Geometry2DCurrentCollector,
)
from .expression_tree.independent_variable import KNOWN_COORD_SYS
from .geometry import standard_spatial_vars
#
# Parameters class and methods
#
from .parameters.parameter_values import ParameterValues
from .parameters import constants
from .parameters import geometric_parameters
from .parameters import electrical_parameters
from .parameters import thermal_parameters
from .parameters import standard_parameters_lithium_ion, standard_parameters_lead_acid
from .parameters.print_parameters import print_parameters, print_evaluated_parameters
from .parameters import parameter_sets
#
# Mesh and Discretisation classes
#
from .discretisations.discretisation import Discretisation
from .discretisations.discretisation import has_bc_of_form
from .meshes.meshes import Mesh, SubMesh, MeshGenerator
from .meshes.zero_dimensional_submesh import SubMesh0D
from .meshes.one_dimensional_submeshes import (
SubMesh1D,
Uniform1DSubMesh,
Exponential1DSubMesh,
Chebyshev1DSubMesh,
UserSupplied1DSubMesh,
)
from .meshes.scikit_fem_submeshes import (
ScikitSubMesh2D,
ScikitUniform2DSubMesh,
ScikitExponential2DSubMesh,
ScikitChebyshev2DSubMesh,
UserSupplied2DSubMesh,
)
#
# Spatial Methods
#
from .spatial_methods.spatial_method import SpatialMethod
from .spatial_methods.zero_dimensional_method import ZeroDimensionalSpatialMethod
from .spatial_methods.finite_volume import FiniteVolume
from .spatial_methods.scikit_finite_element import ScikitFiniteElement
#
# Solver classes
#
from .solvers.solution import Solution, _BaseSolution
from .solvers.processed_variable import ProcessedVariable
from .solvers.processed_symbolic_variable import ProcessedSymbolicVariable
from .solvers.base_solver import BaseSolver
from .solvers.dummy_solver import DummySolver
from .solvers.algebraic_solver import AlgebraicSolver
from .solvers.casadi_solver import CasadiSolver
from .solvers.casadi_algebraic_solver import CasadiAlgebraicSolver
from .solvers.scikits_dae_solver import ScikitsDaeSolver
from .solvers.scikits_ode_solver import ScikitsOdeSolver, have_scikits_odes
from .solvers.scipy_solver import ScipySolver
from .solvers.idaklu_solver import IDAKLUSolver, have_idaklu
#
# Experiments
#
from .experiments.experiment import Experiment
from . import experiments
#
# other
#
from .quick_plot import QuickPlot, dynamic_plot, ax_min, ax_max
from .simulation import Simulation, load_sim, is_notebook
#
# Remove any imported modules, so we don't expose them as part of pybamm
#
del sys