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.backing.rigid(omega, k_x)[source]
pymls.backing.transmission(omega, k_x)[source]

pymls.analysis module

class pymls.analysis.Analysis(name, freqs, angles, enable_stochastic=False)[source]

Bases: object

pymls.interface package

Submodules

pymls.interface.interfaces module

pymls.interface.interfaces.elastic_fluid_interface(O)[source]
pymls.interface.interfaces.elastic_pem_interface(O)[source]
pymls.interface.interfaces.fluid_elastic_interface(O)[source]
pymls.interface.interfaces.fluid_pem_interface(O)[source]
pymls.interface.interfaces.pem_elastic_interface(O)[source]
pymls.interface.interfaces.pem_fluid_interface(O)[source]

pymls.interface.utils module

pymls.interface.utils.generic_interface(medium_left, medium_right)[source]

Returns a callable to the interface function corresponding to the two given media.

Note: interface functions are not symmetrical ( generic_interface(m1, m2) != generic_interface(m2, m1) ).

pymls.interface.utils.rigid_interface(medium)[source]

Returns a callable to the rigid backing function corresponding to the given media.

Module contents

pymls.layers package

Submodules

pymls.layers.elastic module

pymls.layers.elastic.transfert_elastic(Omega_minus, omega, k_x, medium, d)[source]

pymls.layers.fluid module

pymls.layers.fluid.transfert_fluid(Omega_minus, omega, k_x, medium, d)[source]

pymls.layers.layer module

class pymls.layers.layer.Layer(medium, thickness, name='Unnamed Layer')[source]

Bases: object

Methods

register  
update_frequency  
register(hook_name)[source]
update_frequency(omega)[source]
class pymls.layers.layer.StochasticLayer(medium, thickness, stochastic_param, pdf, name='Unnamed Layer')[source]

Bases: pymls.layers.layer.Layer

Methods

register  
reinit  
update_frequency  
reinit()[source]

pymls.layers.pem module

pymls.layers.pem.transfert_pem(Omega_minus, omega, k_x, medium, d)[source]

pymls.layers.screen module

pymls.layers.screen.transfert_screen(Omega_minus, omega, k_x, m, d)[source]

pymls.layers.utils module

pymls.layers.utils.generic_layer(medium)[source]

Module contents

pymls.media package

Module contents

pymls.media.medium
pymls.media.fluid
pymls.media.eqf
pymls.media.air
pymls.media.elastic
pymls.media.pem
pymls.media.screen

pymls.utils package

Submodules

pymls.utils.hdf5_export module

pymls.utils.indicators module

pymls.utils.indicators.TL_from_T(T)[source]

Compute the Transmission Loss from the Transmission coefficient

pymls.utils.indicators.alpha_from_R(R)[source]

Compute the absorption coefficient from the Reflexion coefficient

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>}
extract_from_yaml(yaml=None)[source]
from_file(filename)[source]
parse_yaml()[source]
yaml_is_valid()[source]

Module contents

Module contents

Indices and tables