josie package

Subpackages

Submodules

josie.bc module

class josie.bc.BoundaryCondition(bc)

Bases: object

A BoundaryCondition is a collection of ScalarBC, one per each fields of the Problem.

bc

A State instance whose elements per each field are not float but ScalarBC instead

>>> from josie.state import StateTemplate
>>> MyState = StateTemplate("u", "v")
>>> mybc = BoundaryCondition(MyState(Dirichlet(0), Neumann(1)))
__call__(cells, boundary, t)
Parameters
  • mesh – A Mesh object that contains informations on cells data and time instant

  • boundary (Boundary) – A Boundary object representing the mesh boundary on which the BoundaryCondition must be applied

  • t (float) – The time instant to be used to update time dependent ScalarBC

init(cells, boundary)

Used to initialize the individual ScalarBC per each field

class josie.bc.Dirichlet(value: ImposedValue, constant: bool = False)

Bases: josie.bc.ScalarBC

A ScalarBC that fixes a value of a field on the boundary.

Assuming we want to impose the value Q = Q_D on the (left, as an example) boundary, we can assume that the value on the boundary is approximated by:

\frac{Q_{0,j} + Q_\text{ghost}}{2} = Q_D

That means we can impose the ScalarBC assigning the value of

Q_\text{ghost} = 2Q_D - Q_{0,j}

to the ghost cell.

Parameters
  • value

    The value of the field to be imposed on the boundary. It can have different types:

    • A float. Then it’s the scalar constant value for the

    individual field for which we want to apply the BC for. In this case the object returned is of type _ConstantDirichlet in order to optimize since we know it’s constant

    • A BCCallable. It is called on the cells of the boundary in

    order to provide a non-constant boundary condition

    • A State of size

      System Message: WARNING/2 (\numberof{fields})

      latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2020-10-01> patch level 4 L3 programming layer <2021-01-09> xparse <2020-03-03> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2020/04/10 v1.4m Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) (/usr/share/texlive/texmf-dist/tex/latex/physics/physics.sty (/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty (/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty (/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-dvips.def)) (/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse-generic.tex)) ) (/usr/share/texmf/tex/latex/lm/lmodern.sty) (/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx.sty (/usr/share/texlive/texmf-dist/tex/latex/tools/array.sty) (/usr/share/texlive/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty) (/usr/share/texlive/texmf-dist/tex/latex/translator/translator.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty))) (/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty (/usr/share/texmf/tex/latex/lm/t1lmr.fd)) (/usr/share/texmf/tex/latex/preview/preview.sty (/usr/share/texmf/tex/latex/preview/prtightpage.def)) (./math.aux) (/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx-abbreviations.cfg) (/usr/share/texlive/texmf-dist/tex/latex/translator/translator-basic-dictionary -English.dict) Preview: Fontsize 12pt (/usr/share/texmf/tex/latex/lm/ot1lmr.fd) (/usr/share/texmf/tex/latex/lm/omllmm.fd) (/usr/share/texmf/tex/latex/lm/omslmsy.fd) (/usr/share/texmf/tex/latex/lm/omxlmex.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) (/usr/share/texmf/tex/latex/lm/ot1lmss.fd) (/usr/share/texmf/tex/latex/lm/ot1lmtt.fd) ! Undefined control sequence. <recently read> \numberof l.240 \fontsize{14}{17}\selectfont $\numberof {fields}$ Preview: Tightpage -32891 -32891 32891 32891 [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 1636 bytes). Transcript written on math.log.

      , each element is

    one of the two previous options. Used as a shortcut to impose the same ScalarBC for all the fields

  • constant

    Set this flag to True to explicitly force the creation of a constant boundary condition. A constant BC is optimized to reduce the number of calls.

    Dirichlet normally is capable to understand automatically if you are providing a constant imposed value: if you provide a constant scalar float or int (or a State containing a scalar value for each field). If you provide a BCCallable then it cannot automatically infer it your callable is actually only a function of space (i.e. it does not change at every time step) or not. If you want to optimize the call, you need to explicitly set constant to True.

set_value

A SetValueCallable that can be used to provide a specific value the ScalarBC needs to impose. E.g. * In the case of Dirichlet, the set_value gives the value of the fields to impose on the boundary.

  • In the case of Neumann it provides a callable that returns

the value of the gradient to impose on the boundary

Type

BCCallable

__call__(cells, ghost_cells, field, t)
Parameters
  • cells (CellSet) – A CellSet containing the state of the mesh cells

  • ghosts_cells – A CellSet containing the ghost cells associated to the Boundary the BoundaryCondition is applied to

  • field (int) – The field to which the ScalarBC is applied to

  • t (float) – The time instant to which this ScalarBC must be evaluated (useful for time-dependent BCs)

Returns

Return type

The value of the field on the ghost cell

set_value: BCCallable
class josie.bc.Neumann(value: ImposedValue, constant: bool = False)

Bases: josie.bc.Dirichlet

A ScalarBC that fixes a value of the gradient of a field on the boundary.

Assuming we want to impose the value of the gradient \frac{\partial
Q}{\partial \hat{\mathbf{n}}} = Q_N of the state on the (left, as an example) boundary, we can assume that the value of the gradient on the boundary is approximated by:

\frac{Q_{0,j} - Q_\text{ghost}}{\Delta x} = Q_N

That means we can impose the ScalarBC assigning the value of

Q_\text{ghost} = Q_{0,j} - Q_N

to the ghost cell (assuming a \Delta x = 1)

Parameters

value

The value of the field to be imposed on the boundary. It can have different types:

  • A float. Then it’s the scalar constant value for the

individual field for which we want to apply the BC for

  • A Callable[[CellSet, t], np.ndarray]. It is called on the

cells of the boundary in order to provide a non-constant boundary condition

  • A State of size

    System Message: WARNING/2 (\numberof{fields})

    latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2020-10-01> patch level 4 L3 programming layer <2021-01-09> xparse <2020-03-03> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2020/04/10 v1.4m Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) (/usr/share/texlive/texmf-dist/tex/latex/physics/physics.sty (/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty (/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty (/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-dvips.def)) (/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse-generic.tex)) ) (/usr/share/texmf/tex/latex/lm/lmodern.sty) (/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx.sty (/usr/share/texlive/texmf-dist/tex/latex/tools/array.sty) (/usr/share/texlive/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty) (/usr/share/texlive/texmf-dist/tex/latex/translator/translator.sty (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty))) (/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty (/usr/share/texmf/tex/latex/lm/t1lmr.fd)) (/usr/share/texmf/tex/latex/preview/preview.sty (/usr/share/texmf/tex/latex/preview/prtightpage.def)) (./math.aux) (/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx-abbreviations.cfg) (/usr/share/texlive/texmf-dist/tex/latex/translator/translator-basic-dictionary -English.dict) Preview: Fontsize 12pt (/usr/share/texmf/tex/latex/lm/ot1lmr.fd) (/usr/share/texmf/tex/latex/lm/omllmm.fd) (/usr/share/texmf/tex/latex/lm/omslmsy.fd) (/usr/share/texmf/tex/latex/lm/omxlmex.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) (/usr/share/texmf/tex/latex/lm/ot1lmss.fd) (/usr/share/texmf/tex/latex/lm/ot1lmtt.fd) ! Undefined control sequence. <recently read> \numberof l.240 \fontsize{14}{17}\selectfont $\numberof {fields}$ Preview: Tightpage -32891 -32891 32891 32891 [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 1636 bytes). Transcript written on math.log.

    , each element is

one of the two previous options. Used as a shortcut to impose the same ScalarBC for all the fields

__call__(cells, ghost_cells, field, t)
Parameters
  • cells (CellSet) – A CellSet containing the state of the mesh cells

  • ghosts_cells – A CellSet containing the ghost cells associated to the Boundary the BoundaryCondition is applied to

  • field (int) – The field to which the ScalarBC is applied to

  • t (float) – The time instant to which this ScalarBC must be evaluated (useful for time-dependent BCs)

Returns

Return type

The value of the field on the ghost cell

set_value: BCCallable
class josie.bc.NeumannDirichlet(neumann_value: ImposedValue, dirichlet_value: ImposedValue, partition_fun: Callable[[np.ndarray], np.ndarray])

Bases: josie.bc.ScalarBC

A ScalarBC that applies a Dirichlet on a part of the domain and a Neumann on the rest of it.

Parameters
  • neumann_value – The value of the gradient to use for the Neumann partition of the boundary

  • dirichlet_value – The value of the State to use for the Dirichlet partition of the boundary

  • partition_fun (Callable[[josie.bc.NeumannDirichlet, numpy.ndarray], numpy.ndarray]) – A callable that takes as input the coordinates of the boundary cells and returns the indices of the cells for which the Dirichlet boundary condition has to be applied

__call__(cells, ghost_cells, field, t)
Parameters
  • cells (CellSet) – A CellSet containing the state of the mesh cells

  • ghosts_cells – A CellSet containing the ghost cells associated to the Boundary the BoundaryCondition is applied to

  • field (int) – The field to which the ScalarBC is applied to

  • t (float) – The time instant to which this ScalarBC must be evaluated (useful for time-dependent BCs)

Returns

Return type

The value of the field on the ghost cell

dirichlet: josie.bc.Dirichlet
init(cells)

This method is used to initialize the datastructures used to store the ghost values and avoid multiple allocations.

It’s useful for constant ScalarBC to avoid to recompute the same value at each time step: you just store it ones here

By default it does nothing

Parameters
  • cells (CellSet) – The boundary cells to which this ScalarBC is applied

  • field – The field on which this ScalarBC is applied (i.e. velocity)

neumann: josie.bc.Neumann
partition_fun: Callable[[josie.bc.NeumannDirichlet, numpy.ndarray], numpy.ndarray]
class josie.bc.Periodic(side)

Bases: josie.bc.BoundaryCondition

A BoundaryCondition that connects one side of the domain to the other. In general is more straighforward to use the :func`make_periodic` function on a couple of BoundaryCurve that needs to be linked periodically

That means the neighbour cells of the cells on one domain are the cells on the other side of the domain. In other words, as an example, given a cell on the left boundary, identified by the indices i,j = (0, j), i.e. C_{0,j}, its west neighbour cell needs to be C_{N, j}, being N the number of cells along the x-direction (i.e. for increasing index i)

Parameters

side (PeriodicSide) – The side on which the Periodic BC is configured

Raises

ValueError – If side is not recognized

__call__(cells, boundary, t)
Parameters
  • mesh – A Mesh object that contains informations on cells data and time instant

  • boundary (Boundary) – A Boundary object representing the mesh boundary on which the BoundaryCondition must be applied

  • t (float) – The time instant to be used to update time dependent ScalarBC

init(cells, boundary)

Used to initialize the individual ScalarBC per each field

class josie.bc.PeriodicSide(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)

Bases: josie.data.NoAliasEnum

A Enum encapsulating the 4 indexing possibilities of a Periodic ScalarBC

BOTTOM = (slice(None, None, None), -1)
LEFT = (-1, slice(None, None, None))
RIGHT = (0, slice(None, None, None))
TOP = (slice(None, None, None), 0)
class josie.bc.ScalarBC

Bases: abc.ABC

A ScalarBC is implemented as a callable that sets the equivalent cell value for the ghost cells for the specific field

abstract __call__(cells, ghost_cells, field, t)
Parameters
  • cells (CellSet) – A CellSet containing the state of the mesh cells

  • ghosts_cells – A CellSet containing the ghost cells associated to the Boundary the BoundaryCondition is applied to

  • field (int) – The field to which the ScalarBC is applied to

  • t (float) – The time instant to which this ScalarBC must be evaluated (useful for time-dependent BCs)

Returns

Return type

The value of the field on the ghost cell

init(cells)

This method is used to initialize the datastructures used to store the ghost values and avoid multiple allocations.

It’s useful for constant ScalarBC to avoid to recompute the same value at each time step: you just store it ones here

By default it does nothing

Parameters
  • cells (CellSet) – The boundary cells to which this ScalarBC is applied

  • field – The field on which this ScalarBC is applied (i.e. velocity)

class josie.bc.SetValueCallable(value)

Bases: object

Used to convert the bare float value to a callable returning constant value for all the cells. Used for Dirichlet and children classes

__call__(cells, t)

Call self as a function.

Return type

np.ndarray

josie.bc.make_periodic(first, second, direction)

This handy function takes as arguments two opposed BoundaryCurve and configures them correctly to provide periodic behaviour.

Parameters
Return type

Tuple[BoundaryCurve, BoundaryCurve]

Returns

  • first – The first BoundaryCurve whose bc attribute is correctly configured

  • second – The second BoundaryCurve whose bc attribute is correctly configured

josie.data module

class josie.data.NoAliasEnum(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)

Bases: aenum.Enum

Allow pickling of NoAlias IntEnum

class josie.data.NoAliasIntEnum(value=<no_arg>, names=None, module=None, type=None, start=1, boundary=None)

Bases: josie.data.NoAliasEnum, aenum.IntEnum

An enumeration.

class josie.data.StateElement(time, data)

Bases: object

An handy class to store the state of a simulation

data: Dict[str, numpy.ndarray]
time: float
josie.data.unpickle_noaliasenum(cls, name)

josie.dimension module

class josie.dimension.Dimensionality(value)

Bases: enum.IntEnum

An enumeration.

ONED = 1
THREED = 3
TWOD = 2
ZEROD = 0

josie.exceptions module

exception josie.exceptions.InvalidMesh

Bases: Exception

josie.fields module

class josie.fields.Field(name: str, value: int)

Bases: int

A class that acts as a int used in FieldsMeta to store field name and its value

name: str
value: int
class josie.fields.Fields(clsname: Optional[str] = None, fields: Optional[dict] = None, *args, **kwargs)

Bases: object

class josie.fields.FieldsMeta(name, bases, clsdict)

Bases: type

This metaclass reproduces in a simpler form the behaviour of Enum. It tracks all the defined attributes of a class, it precomputes the number of fields and replaces the fields that have no int value with the corresponding int

names()

Returns a list of field names

Return type

List[str]

josie.geometry module

josie.math module

General purpose math primitives

class josie.math.Direction(value)

Bases: enum.IntEnum

An Enum encapsulating the coordinates indices

X = 0
Y = 1
Z = 2
class josie.math.R3

Bases: object

An Enum encapsulating the unit vectors for a cartesia R2 space

X = array([1., 0.])
Y = array([0., 1.])
josie.math.map01to(x, a, b)

Maps x in [0, 1] \to [a, b]

josie.nbconvert module

class josie.nbconvert.BinderBadgePreprocessor(**kwargs)

Bases: nbconvert.preprocessors.base.Preprocessor

This preprocessor adds a BinderBadge on top of the notebook

BINDER_URL = 'https://mybinder.org'
preprocess(nb, resources)

Preprocessing to apply on each notebook.

Must return modified nb, resources.

If you wish to apply your preprocessing to each cell, you might want to override preprocess_cell method instead.

Parameters
  • nb (NotebookNode) – Notebook being converted

  • resources (dictionary) – Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.

class josie.nbconvert.CleanOutputPreprocessor(**kwargs)

Bases: nbconvert.preprocessors.tagremove.TagRemovePreprocessor

A pre-processor that removes cells tagged with remove_output

remove_all_outputs_tags = {'remove_output'}
remove_cell_tags = {'skip_conversion'}
class josie.nbconvert.MathFixPreprocessor(**kwargs)

Bases: nbconvert.preprocessors.base.Preprocessor

This preprocessor fix the markdown for the math formulas using the :mod`recommonmark` notation

preprocess_cell(cell, resources, index)

Override if you want to apply some preprocessing to each cell. Must return modified cell and resource dictionary.

Parameters
  • cell (NotebookNode cell) – Notebook cell being processed

  • resources (dictionary) – Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.

  • index (int) – Index of the cell being processed

regexs = [RegexReplace(regex='\\\\begin\\{[a-zA-Z]+\\}([\\s\\S]*?)\\\\end\\{[a-zA-Z]+\\}', replace='```math\\n \\1 \\n```'), RegexReplace(regex='\\$\\$\\n([ \\S]+)\\n\\$\\$', replace='```math\\n \\1 \\n```'), RegexReplace(regex='\\$(.*)\\$', replace='`$ \\1 $`')]
class josie.nbconvert.MdBinderExporter(**kwargs)

Bases: nbconvert.exporters.templateexporter.TemplateExporter

A nbconvert exporter that exports Notebooks as markdown files with a Binder badge on top ready to be used in Sphinx documentation

BINDER_URL = 'https://mybinder.org'
file_extension = '.md'
preprocessors = [<class 'josie.nbconvert.MplInlinePreprocessor'>, <class 'nbconvert.preprocessors.execute.ExecutePreprocessor'>, <class 'josie.nbconvert.SkipPreprocessor'>, <class 'josie.nbconvert.CleanOutputPreprocessor'>, <class 'josie.nbconvert.MathFixPreprocessor'>, <class 'josie.nbconvert.BinderBadgePreprocessor'>]
template_file = 'markdown/index.md.j2'
class josie.nbconvert.MplInlinePreprocessor(**kwargs)

Bases: josie.nbconvert.MathFixPreprocessor

This preprocessors replaces the magic command for matplolib to inline.

regexs = [RegexReplace(regex='(%matplotlib) .*', replace='\\1 inline')]
class josie.nbconvert.RegexReplace(regex, replace)

Bases: object

A dataclass used to store regex patterns and their replacements

regex: str
replace: str
class josie.nbconvert.SkipPreprocessor(**kwargs)

Bases: nbconvert.preprocessors.base.Preprocessor

A Preprocessor that removes cell tagged as “skip”

check_cell_conditions(cell, resources, index)
preprocess(nb, resources)

Preprocessing to apply on each notebook.

Must return modified nb, resources.

If you wish to apply your preprocessing to each cell, you might want to override preprocess_cell method instead.

Parameters
  • nb (NotebookNode) – Notebook being converted

  • resources (dictionary) – Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.

josie.ode module

Handy objects to speed up the setup of a simulation for a problem governed by an Ordinary Differential Equation (ODE) (i.e. time-varying only)

class josie.ode.OdeProblem(f)

Bases: josie.problem.Problem

s(cells, t)

This returns the values of the source terms

A general problem can be written in a compact way:

\pdeFull

This method needs to return \pdeSource

Parameters
  • cells (Union[MeshCellSet, CellSet]) – A MeshCellSet that contains the cell data

  • t (float) – Time instant

Returns

An array of dimension Nx \times Ny \times N_\text{eqs} containing the computed source terms

Return type

s

class josie.ode.OdeSolver(Q0, dt, Scheme, f, *args, **kwargs)

Bases: josie.solver.Solver

A convenience solver that takes care of all the required setups of objects to speed up the configuration of an ODE problem

\odeProblem

Parameters
  • Q – A State describing the state variable. For example for an oscilator the state is \pdeState = \qty(x, v) where x is the position and v is the velocity of a point connected to the oscillator

  • Scheme (Type[TimeScheme]) – A TimeScheme to be used to integrate the problem

  • f (Callable[[State, float], State]) – The RHS of the ODE problem

  • Q0 (State) – The initial state value

solve(final_time, WriterClass=<class 'josie.io.write.writer.MemoryWriter'>)

This method solves the ODE system using a

Parameters
  • final_time (float) – The final time for the time integration

  • writer – The Writer to use to perform the integration. By default MemoryWriter is used.

t: float

josie.problem module

class josie.problem.Problem(**kwargs)

Bases: object

A class representing a physical problem to be solved (governed by a PDE).

A general problem can be written in a compact way:

\pdeFull

A concrete instance of this class potentially provides the terms

\pdeTermList

B(cells)

This returns the tensor that pre-multiplies the non-conservative term of the problem.

A general problem can be written in a compact way:

\pdeFull

This method needs to return \pdeNonConservativeMultiplier

Parameters

state_array – The State array containing the values of all the fields

Returns

An array of dimension Nx \times Ny \times N_\text{eqs}
\times N_\text{state} \times N_\text{dim} containing the computed pre-multiplier tensor

Return type

B

F(cells)

The convective flux operator \pdeConvective

Parameters

cells (Union[CellSet, MeshCellSet]) – A MeshCellSet that contains the cell data

Returns

An array of dimension Nx \times Ny \times N_\text{eqs}
\times N_\text{dim} containing the computed convective flux for the given problem

Return type

F

K(cells)

This returns the tensor that pre-multiplies the gradient in the diffusive term of the problem.

A general problem can be written in a compact way:

\pdeFull

This method needs to return \pdeDiffusiveMultiplier

Parameters

cells (Union[CellSet, MeshCellSet]) – A MeshCellSet that contains the cell data

Returns

An array of dimension Nx \times Ny \times N_\text{eqs}
\times N_\text{state} \times N_\text{dim} \times N_\text{dim} containing the computed pre-multiplier tensor

Return type

D

s(cells, t)

This returns the values of the source terms

A general problem can be written in a compact way:

\pdeFull

This method needs to return \pdeSource

Parameters
  • cells (Union[CellSet, MeshCellSet]) – A MeshCellSet that contains the cell data

  • t (float) – Time instant

Returns

An array of dimension Nx \times Ny \times N_\text{eqs} containing the computed source terms

Return type

s

josie.solver module

class josie.solver.Solver(mesh, Q, scheme)

Bases: object

This class is used to solve a problem governed by PDEs.

Parameters
  • mesh (Mesh) – An instance of the mesh to compute the solution on

  • Q (Type[State]) – A State representing the variables of the problem to be solved

  • scheme (Scheme) – A Scheme instance providing the numerical scheme to be used for the simulation

t

The time instant of the simulation held by the Solver object

Type

float

animate(t)

Animate the simulation. Call animate() for each time instant you want to provide in the animation.

Parameters

t – The time instant to animate

copy()

This methods copies the Solver object into another

Return type

Solver

init(init_fun)

This method initialize the internal values of the cells of the Mesh and the values of the ghost cells that apply the BoundaryCondition for each boundary of the domain

Parameters

init_fun (Callable[[MeshCellSet], NoReturn]) – The function to use to initialize the value in the domain

plot()

Plot the current state of the simulation in a GUI.

show(fields)

Display on screen the given fields

Parameters

fields (Union[List[str], str]) – The fields you want to plot

step(dt)

This method advances one step in time using the Scheme.step() method of the given numerical scheme.

Parameters

dt (float) – Time increment of the step

t: float

josie.state module

class josie.state.State(*args, **kwargs)

Bases: numpy.ndarray

State is a subclass of numpy.ndarray. It behaves like a normal numpy.ndarray except it has additional init methods to ease the usage

A State can be initialized using a StateTemplate,

>>> Q = StateTemplate("rho", "rhoU", "rhoV")
>>> state = np.array([0, 1, 2]).view(Q)
>>> assert state[state.fields.rho] == 0
>>> assert state[state.fields.rhoU] == 1
>>> assert state[state.fields.rhoV] == 2

or directly providing key-value arguments

>>> state = State(rho=0, rhoU=1, rhoV=2)
>>> assert state[state.fields.rho] == 0
>>> assert state[state.fields.rhoU] == 1
>>> assert state[state.fields.rhoV] == 2

A State can also store non-numeric elements. Check BoundaryCondition for an actual situation in which callables are stored instead of numeric elements.

A State can be manipulated as a normal :class:`numpy.ndarray:

>>> e1 = State([1, 0, 0])
>>> e2 = State([0, 1, 0])
>>> e3 = State([0, 0, 1])
>>> assert np.array_equal(np.cross(e1, e2), e3)

A State can be multidimensional. The last dimension must be the number of states defined in the StateTemplate call. In this case you can get all the values of the state for a specific variable:

>>> state = np.random.random((10, 10, 3)).view(Q)
>>> assert np.array_equal(state[..., state.fields.rho], state[..., 0])
>>> assert np.array_equal(state[..., state.fields.rhoU],state[..., 1])
fields: Type[<class ‘josie.fields.Fields’>]
classmethod from_mesh(mesh)

Initialize an empty class:State object of the right dimensiosn for the given class:Mesh

Return type

State

classmethod list_to_enum(fields)

Convert a list of textual fields to the class:IntEnum that needs to be stored in this class fields

Return type

Fields

josie.state.StateTemplate(*fields)

A factory for a State.

It allows you to create at will a State class for which you can access its variables (e.g. the velocity \mathbf{U}) using the attribute fields, that is an IntEnum (and not only by index).

Parameters

fields (str) – A list of (scalar) fields composing the state

A scalar State as for the advection equation

>>> Q = StateTemplate("u")

Than you can concretize the state with a value

>>> zero = Q(0)

You can also create higher dimensional states, for examples the state of the 2D Euler compressible equations

>>> Q = StateTemplate("rho", "rhoU", "rhoV", "E")
>>> zero = Q(0, 0, 0, 0)
>>> assert zero[Q.fields.rho] == 0
Return type

Type[State]

class josie.state.SubsetState(*args, **kwargs)

Bases: josie.state.State

This class stores a subset of :class`State`, filtered by field name. It also stores a mapping of the indices in State.fields corresponding to the SubsetState.fields in self._subset_fields_map

full_state_fields

The fields of the full State

josie.state.unpickle_state(d, array)

josie.transport module

class josie.transport.Transport

Bases: abc.ABC

A class providing the transport coefficients

Module contents