simudo.io package

Submodules

simudo.io.csv module

class simudo.io.csv.LineCutCsvPlot(filename, function_subspace_registry=None)[source]

Bases: simudo.io.xdmf.PlotAddMixin

close()[source]
new(timestamp)[source]
resolution = 5001
timestamp = 0.0

simudo.io.h5yaml module

class simudo.io.h5yaml.BaseCustomTag[source]

Bases: object

classmethod register_in_dumper(dumper)[source]
classmethod register_in_loader(loader)[source]
yaml_classes = ()
yaml_tag = None
class simudo.io.h5yaml.BaseDolfinMeshFunctionTag(dolfin_h5_manager, key, **kwargs)[source]

Bases: simudo.io.h5yaml.DolfinObjectTag

yaml_tag

classmethod(function) -> method

Convert a function to be a class method.

A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

class C:

@classmethod def f(cls, arg1, arg2, …):

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.

Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.

class simudo.io.h5yaml.ClassProperty[source]

Bases: property

class simudo.io.h5yaml.DolfinFunctionTag(scale=1.0, **kwargs)[source]

Bases: simudo.io.h5yaml.ScaleDolfinObjectTag

yaml_classes = (<class 'dolfin.function.function.Function'>,)
yaml_tag = '!dolfin/function'
class simudo.io.h5yaml.DolfinH5Manager(basepath)[source]

Bases: object

ensure_dir()[source]
filename_from_key(key)[source]
open(comm, key, mode)[source]

returns (key, dolfin.HDF5File)

pass key=None to have a new one randomly generated

class simudo.io.h5yaml.DolfinMeshFunctionBoolTag(dolfin_h5_manager, key, **kwargs)[source]

Bases: simudo.io.h5yaml.BaseDolfinMeshFunctionTag

meshfunction_type_name = 'bool'
yaml_classes = (<class 'dolfin.cpp.mesh.MeshFunctionBool'>,)
class simudo.io.h5yaml.DolfinMeshFunctionDoubleTag(scale=1.0, **kwargs)[source]

Bases: simudo.io.h5yaml.ScaleMixin, simudo.io.h5yaml.BaseDolfinMeshFunctionTag

meshfunction_type_name = 'double'
yaml_classes = (<class 'dolfin.cpp.mesh.MeshFunctionDouble'>,)
class simudo.io.h5yaml.DolfinMeshFunctionIntTag(dolfin_h5_manager, key, **kwargs)[source]

Bases: simudo.io.h5yaml.BaseDolfinMeshFunctionTag

meshfunction_type_name = 'int'
yaml_classes = (<class 'dolfin.cpp.mesh.MeshFunctionInt'>,)
class simudo.io.h5yaml.DolfinMeshFunctionSizetTag(dolfin_h5_manager, key, **kwargs)[source]

Bases: simudo.io.h5yaml.BaseDolfinMeshFunctionTag

meshfunction_type_name = 'size_t'
yaml_classes = (<class 'dolfin.cpp.mesh.MeshFunctionSizet'>,)
class simudo.io.h5yaml.DolfinMeshTag(dolfin_h5_manager, key, **kwargs)[source]

Bases: simudo.io.h5yaml.DolfinObjectTag

load_pass = -10
yaml_classes = (<class 'dolfin.cpp.mesh.Mesh'>,)
yaml_tag = '!dolfin/mesh'
class simudo.io.h5yaml.DolfinObjectTag(dolfin_h5_manager, key, **kwargs)[source]

Bases: simudo.io.h5yaml.BaseCustomTag

classmethod from_yaml(loader, node)[source]
classmethod get_object_mpi_comm(obj)[source]
load_into(obj, comm=None)[source]
load_pass = 0
needs_load_into = True
classmethod to_yaml(dumper, data)[source]
class simudo.io.h5yaml.FrozenSetTag[source]

Bases: simudo.io.h5yaml.BaseCustomTag

classmethod from_yaml(loader, node)[source]
classmethod to_yaml(dumper, data)[source]
yaml_classes = (<class 'frozenset'>,)
yaml_tag = '!frozenset'
class simudo.io.h5yaml.PintQTag[source]

Bases: simudo.io.h5yaml.BaseCustomTag

classmethod from_yaml(loader, node)[source]
classmethod to_yaml(dumper, data)[source]
yaml_classes = (<class 'pint.quantity._Quantity'>,)
yaml_tag = '!pintq'
class simudo.io.h5yaml.ScaleDolfinObjectTag(scale=1.0, **kwargs)[source]

Bases: simudo.io.h5yaml.ScaleMixin, simudo.io.h5yaml.DolfinObjectTag

class simudo.io.h5yaml.ScaleMixin(scale=1.0, **kwargs)[source]

Bases: object

class simudo.io.h5yaml.SolutionIOTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

helper_test_roundtrip(dedup)[source]
test_roundtrip()[source]
test_roundtrip_with_dedup()[source]
class simudo.io.h5yaml.XDumper(*args, **kwargs)[source]

Bases: yaml.dumper.Dumper

ignore_aliases(data)[source]
yaml_multi_representers = {<class 'object'>: <function Representer.represent_object>, <class 'dolfin.cpp.mesh.Mesh'>: <bound method DolfinObjectTag.to_yaml of <class 'simudo.io.h5yaml.DolfinMeshTag'>>, <class 'dolfin.function.function.Function'>: <bound method DolfinObjectTag.to_yaml of <class 'simudo.io.h5yaml.DolfinFunctionTag'>>, <class 'dolfin.cpp.mesh.MeshFunctionSizet'>: <bound method DolfinObjectTag.to_yaml of <class 'simudo.io.h5yaml.DolfinMeshFunctionSizetTag'>>, <class 'dolfin.cpp.mesh.MeshFunctionInt'>: <bound method DolfinObjectTag.to_yaml of <class 'simudo.io.h5yaml.DolfinMeshFunctionIntTag'>>, <class 'dolfin.cpp.mesh.MeshFunctionDouble'>: <bound method DolfinObjectTag.to_yaml of <class 'simudo.io.h5yaml.DolfinMeshFunctionDoubleTag'>>, <class 'dolfin.cpp.mesh.MeshFunctionBool'>: <bound method DolfinObjectTag.to_yaml of <class 'simudo.io.h5yaml.DolfinMeshFunctionBoolTag'>>, <class 'frozenset'>: <bound method FrozenSetTag.to_yaml of <class 'simudo.io.h5yaml.FrozenSetTag'>>, <class 'pint.quantity._Quantity'>: <bound method PintQTag.to_yaml of <class 'simudo.io.h5yaml.PintQTag'>>}
class simudo.io.h5yaml.XLoader(*args, **kwargs)[source]

Bases: yaml.loader.Loader

yaml_constructors = {'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:int': <function SafeConstructor.construct_yaml_int>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>, 'tag:yaml.org,2002:omap': <function SafeConstructor.construct_yaml_omap>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:str': <function SafeConstructor.construct_yaml_str>, 'tag:yaml.org,2002:seq': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:map': <function SafeConstructor.construct_yaml_map>, None: <function SafeConstructor.construct_undefined>, 'tag:yaml.org,2002:python/none': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:python/bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:python/str': <function Constructor.construct_python_str>, 'tag:yaml.org,2002:python/unicode': <function Constructor.construct_python_unicode>, 'tag:yaml.org,2002:python/bytes': <function Constructor.construct_python_bytes>, 'tag:yaml.org,2002:python/int': <function SafeConstructor.construct_yaml_int>, 'tag:yaml.org,2002:python/long': <function Constructor.construct_python_long>, 'tag:yaml.org,2002:python/float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:python/complex': <function Constructor.construct_python_complex>, 'tag:yaml.org,2002:python/list': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:python/tuple': <function Constructor.construct_python_tuple>, 'tag:yaml.org,2002:python/dict': <function SafeConstructor.construct_yaml_map>, '!dolfin/mesh': <bound method DolfinObjectTag.from_yaml of <class 'simudo.io.h5yaml.DolfinMeshTag'>>, '!dolfin/function': <bound method DolfinObjectTag.from_yaml of <class 'simudo.io.h5yaml.DolfinFunctionTag'>>, '!dolfin/meshfunction/size_t': <bound method DolfinObjectTag.from_yaml of <class 'simudo.io.h5yaml.DolfinMeshFunctionSizetTag'>>, '!dolfin/meshfunction/int': <bound method DolfinObjectTag.from_yaml of <class 'simudo.io.h5yaml.DolfinMeshFunctionIntTag'>>, '!dolfin/meshfunction/double': <bound method DolfinObjectTag.from_yaml of <class 'simudo.io.h5yaml.DolfinMeshFunctionDoubleTag'>>, '!dolfin/meshfunction/bool': <bound method DolfinObjectTag.from_yaml of <class 'simudo.io.h5yaml.DolfinMeshFunctionBoolTag'>>, '!frozenset': <bound method FrozenSetTag.from_yaml of <class 'simudo.io.h5yaml.FrozenSetTag'>>, '!pintq': <bound method PintQTag.from_yaml of <class 'simudo.io.h5yaml.PintQTag'>>}
simudo.io.h5yaml.delete_attached(filename)[source]
simudo.io.h5yaml.dump(data, stream=None, Dumper=None, x_attr_dict=None, pint_unit_registry=None, **kwargs)[source]
simudo.io.h5yaml.kl

alias of simudo.io.h5yaml.PintQTag

simudo.io.h5yaml.load(stream, Loader=None, x_attr_dict=None, pint_unit_registry=None, **kwargs)[source]
simudo.io.h5yaml.xattr(loader_or_dumper)[source]

simudo.io.output_writer module

class simudo.io.output_writer.MetaCSVWriter(filename, meta)[source]

Bases: simudo.util.setattr_init_mixin.SetattrInitMixin

add_row(meta)[source]
class simudo.io.output_writer.MetaExtractorBandInfo(**kwargs)[source]

Bases: simudo.util.setattr_init_mixin.SetattrInitMixin

call()[source]
prefix = 'band_info:'
class simudo.io.output_writer.MetaExtractorIntegrals(**kwargs)[source]

Bases: simudo.util.setattr_init_mixin.SetattrInitMixin

prefix

str – String to add to quantites.

facets

dict – Facet regions where to extract quantities.

cells

dict – Cell regions where to extract quantities.

solution

Solution object.

parameter_value

Parameter value.

meta

Metadata dictionary to write to.

add_quantity(name, location_name, value, units)[source]
add_surface_flux(k, expr, **kwargs)[source]
add_surface_total(k, expr_ds, expr_dS, internal=True, external=True, average=False, units=None)[source]
add_volume_total(k, expr, average=False, units=None)[source]
call()[source]
pdd
prefix = ''
class simudo.io.output_writer.OutputWriter(**kwargs)[source]

Bases: simudo.util.setattr_init_mixin.SetattrInitMixin

Write output data extracted from a solution object.

The output can be any of a plot on a mesh, on a 1D linecut, or in a csv file containing data from multiple solutions during a parameter sweep.

filename_prefix: a prefix to any filenames that will be saved.

plot_mesh: Save data on the original mesh.

plot_1d: Extract data along a 1D line cut and save to a csv file.

format_parameter(solution, parameter_value)[source]
get_iv_prefix(solution, parameter_value)[source]
get_meta_csv_file(filename, meta)[source]
get_plot_prefix(solution, parameter_value)[source]
meta_extractors
write_output(solution, parameter_value)[source]
exception simudo.io.output_writer.ZeroAreaWarning[source]

Bases: RuntimeWarning

simudo.io.output_writer.get_contact_currents(solution, contact_name)[source]

Integrate current flux across the area of a contact.

Returns the electron and hole currents as Pint quantities.

simudo.io.output_writer.solution_plot_1d(plotter, s, timestep, solver=None)[source]

simudo.io.xdmf module

class simudo.io.xdmf.PlotAddMixin[source]

Bases: object

add(name, units, expr, space=None)[source]
class simudo.io.xdmf.XdmfPlot(filename, function_subspace_registry=None)[source]

Bases: simudo.io.xdmf.PlotAddMixin

close()[source]
static delete_partials(filename)[source]
ensure_open()[source]
mpi_comm()[source]
new(timestamp)[source]
open()[source]
partial_xdmf_file = None
timestamp = 0.0
simudo.io.xdmf.magnitude(x)[source]
simudo.io.xdmf.xdmf_combine(filename)[source]

Module contents