pymls: Python Plane Waves Solver¶
pymls allows to solve acoustic propagation problems through structures with multiple layers using Dazel et al.’s method as described in “A stable to model the acoustic response of multilayered structures” (Journal of Applied Physics, 2013, doi: 10.1063/1.4790629 ).
Materials¶
Materials are described using classes from pymls.media
module. They can be either
created from scratch by instanciating the corresponding class and inserting values into
the parameters or reading YAML files.
API documentation¶
pymls.solver module¶
-
exception
pymls.solver.
IncompleteDefinitionError
(msg='The definition is incomplete and no analysis can be performed')[source]¶ Bases:
Exception
Exception raised when attempting to solve an incomplete system
Either missing layers definition or no backing will produce such an error.
-
class
pymls.solver.
Solver
(media=None, analyses=None, layers=None, backing=None)[source]¶ Bases:
object
Stores a system to solve and parameters for the analysis.
Performs analysis and gives back raw unmodified/cleaned results. All post-processing should be done out of this class.
Parameters: - layers (list of Layer/StochasticLayer instances) – The right most layer appears last in the list.
- backing (function reference from pymls.backing) – Describe the type of backing condition
- media (list of Media subclasses, optional) – Stores all media used in the system for later reference
- analyses (list of Analysis instances, optional) – If only one instance is provided with a list, the constructor will wrap it into a list.
-
media
¶ list of Media subclasses, optional
-
layers
¶ list of Layer/StochasticLayer instances
-
backing
¶ function reference from pymls.backing
-
analyses
¶ list of Analysis instances, optional
-
resultset
¶ list of dict – Contains the results for all analysis and metadata
-
solve(frequencies, angles, n_draws, prng_state) : list of dict
Starts the solving process w/w stochastic parameters.
-
check_is_complete() : bool
Check that all required data has been provided and gathers media.
Methods
check_is_complete
()Check that all required data has been provided and gathers media. compute_fields
(layer_id, frequency, theta_inc)Returns the backpropagation matrix from the first interface to layer num. solve
([frequencies, angles, n_draws, prng_state])Starts the solving process w/w stochastic parameters. -
check_is_complete
()[source]¶ Check that all required data has been provided and gathers media.
Returns: True if the described is complete and ready to be solved. Return type: bool Raises: IncompleteDefinitionError
– If the system is incomplete (missing layer or backing)
-
compute_fields
(layer_id, frequency, theta_inc)[source]¶ Returns the backpropagation matrix from the first interface to layer num. layer_id.
Parameters: - frequency (float) – frequency at which backprop is computed
- theta_inc – angle of incidence
- layer_id (int) – id of the layer up to which backpropagate
Returns: layer_func – Function to get the propagation in the layer
Return type: callable
Raises: ValueError : – if the id is invalid
-
solve
(frequencies=None, angles=0, n_draws=1000, prng_state=None)[source]¶ Starts the solving process w/w stochastic parameters.
The function looks for StochasticLayer instances in the layers list and flag them. It creates an Analysis if all parameters are provided upon call and runs the corresponding solver functions for all registered analysis, gathering results in resultset.
Parameters: - frequencies (list, optional) – list of frequency where to compute the analysis. If it isn’t provided and no Analysis has been registered before hand, the function will return nothing.
- angles (optional) – Defaults to 0. Can be a list or anything Analysis can parse to an iterable.
- n_draws (int) – Number of draws for the stochastic analyses.
- prng_state (tuple) – Saved state for Numpy’s pseudo random number generator (see numpy.random.get_state)
- _numpy.random.get_state (.) –
Returns: resultset – Set of all computed results and relevant metadata provided as a dict for easy serialisation.
Return type: dict or list of dict
pymls.backing module¶
pymls.analysis module¶
pymls.interface package¶
Submodules¶
pymls.interface.interfaces module¶
pymls.interface.utils module¶
Module contents¶
pymls.layers package¶
Submodules¶
pymls.layers.elastic module¶
pymls.layers.fluid module¶
pymls.layers.layer module¶
-
class
pymls.layers.layer.
Layer
(medium, thickness, name='Unnamed Layer')[source]¶ Bases:
object
Methods
register update_frequency
-
class
pymls.layers.layer.
StochasticLayer
(medium, thickness, stochastic_param, pdf, name='Unnamed Layer')[source]¶ Bases:
pymls.layers.layer.Layer
Methods
register reinit update_frequency
pymls.layers.pem module¶
pymls.layers.screen module¶
Module contents¶
pymls.media package¶
pymls.utils package¶
Submodules¶
pymls.utils.hdf5_export module¶
pymls.utils.indicators module¶
pymls.utils.yaml_loader module¶
-
class
pymls.utils.yaml_loader.
YamlLoader
[source]¶ Bases:
object
Load a multilayer definition from a yaml file
Methods
extract_from_yaml from_file parse_yaml yaml_is_valid -
EXPECTED_FIELDS
= {'analysis': {'type': [<class 'list'>, <class 'dict'>], 'item_keys': ['type', 'values', 'start', 'end', 'step']}, 'backing': {'type': [<class 'str'>]}, 'materials': {'type': [<class 'dict'>, <class 'dict'>], 'item_keys': ['source']}, 'multilayer': {'type': [<class 'list'>, <class 'dict'>], 'item_keys': ['medium', 'thickness']}}¶
-
KEYS_ANALYSIS
= {'frequency': ['type', 'value'], 'range': ['type', 'start', 'end', 'step']}¶
-
MAP_BACKING
= {'rigid': <function rigid at 0x7ffa5af3f8c0>, 'transmission': <function transmission at 0x7ffa5af55c20>}¶
-