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