pysdic.SDICFixedParametrization#
SDICFixedParametrization class#
- class SDICFixedParametrization(analysis, unknowns, *, vertices=None, components=None, sparse=True)[source]#
A parametrization of the unknowns of a SDIC problem optimizing only the displacements of selected vertices and components of the optimized frames (and all the parameters of the optimized transformations), the other unknowns keeping their value in the analysis. The
pysolvegn.Parametrizationto give topysolvegn.solveis the propertyparametrization.Important
pysolvegn.Parametrizationis notpysdic.Parametrization, despite the same name and a close purpose:pysdic.Parametrizationre-expresses the parameters of apysdic.Transformation(encode/decode, seepysdic.ReparametrizedTransformation).pysolvegn.Parametrizationmaps the unknowns \(\vec{q}\) optimized by the solver to the parameters \(\vec{p} = P(\vec{q})\) given to the terms of apysolvegnproblem.SDICFixedParametrizationbuilds one.
The terms of the problem (
pysdic.SDICCorrelationTerm,pysdic.SDICTemporalRegularizationTerm) keep working on the complete vector \(\vec{p} = [\vec{p}_U, \vec{p}_T]\) ofunknowns. The parametrization is the affine map\[\vec{p} = P(\vec{q}) = \vec{p}_{current} \text{ with } \vec{p}[I] = \vec{q}, \qquad \frac{\partial \vec{p}}{\partial \vec{q}} = S\]where \(I\) are the selected indices (see
pysdic.SDICAnalysis.compute_unknowns_indices()) and \(S\) the constant selection matrix. The values of the unknowns that are not selected are read from the analysis at each call (pysdic.SDICAnalysis.pack_unknowns()): after a convergence written in the analysis (reparametrized_apply()), the same parametrization can be used again for a new resolution, without building it again.Initial vector. With a parametrization, the solver starts from the reduced vector \(\vec{q}_0\) given by
reparametrized_pack(), not fromanalysis.pack_unknowns(unknowns)(the complete vector \(\vec{p}_0\), used without parametrization). The three methods mirror those ofpysdic.SDICAnalysison the reduced vector \(\vec{q}\):Without parametrization (\(\vec{p}\))
With this parametrization (\(\vec{q}\))
analysis.pack_unknowns(unknowns)analysis.unpack_unknowns(unknowns, p)analysis.apply_unknowns(unknowns, p)As for the unknowns, \(\vec{q}\) holds total values (displacements from the reference mesh, parameters of the transformations), not increments.
Warning
With a parametrization, always use
reparametrized_pack(),reparametrized_unpack()andreparametrized_apply()on the vectors of the solver (p0andresult.parametersare reduced vectors \(\vec{q}\)).analysis.pack_unknowns,analysis.unpack_unknownsandanalysis.apply_unknowns(andpack,unpack,applyof the terms) work on the complete vector \(\vec{p}\): giving them \(\vec{q}\) raises an error (wrong size) or, worse, misplaces the values if the sizes happen to match.q0 = parametrization.reparametrized_pack() # NOT analysis.pack_unknowns(unknowns) result = pysolvegn.solve(terms, q0, parametrization=parametrization.parametrization) parametrization.reparametrized_apply(result.parameters) # NOT analysis.apply_unknowns(unknowns, ...)
Typical uses:
optimize only the vertices supporting integration points (see
pysdic.compute_supported_vertices()), the other ones keeping their displacement;optimize only some components, e.g. the in-plane components \(x\) and \(y\).
The object is immutable:
with_unknowns()andwith_options()create a new parametrization.- Parameters:
analysis (
pysdic.SDICAnalysis) – The analysis of the problem, shared with its terms.unknowns (
pysdic.SDICUnknowns) – The unknowns of the problem, shared with its terms (validated by the analysis).vertices (Optional[ArrayLike], optional) – The vertices whose displacement is optimized: indices or a boolean mask of shape \((N_v,)\). By default, all the vertices.
components (Optional[Sequence[Integral]], optional) – The components of the displacement that are optimized. By default, all the components.
sparse (bool, optional (default:
True)) – If True, the Jacobian \(S\) is ascipy.sparse.csr_matrix(recommended: the dense matrix has \(\dim(\vec{p}) \times \dim(\vec{q})\) entries).
- Raises:
TypeError – If
analysisis not apysdic.SDICAnalysisorunknownsnot apysdic.SDICUnknowns.ValueError – If no unknown is selected, or an input has a wrong value.
Examples
Measure the displacements of several frames, only for the vertices that support integration points and only for the in-plane components:
import pysolvegn from pysdic import (SDICCorrelationTerm, SDICFixedParametrization, SDICUnknowns, compute_supported_vertices) unknowns = SDICUnknowns([1], []) correlation = SDICCorrelationTerm(analysis, unknowns, integration_points, pairings) vertices = compute_supported_vertices(analysis.mesh, integration_points) fixed = SDICFixedParametrization(analysis, unknowns, vertices=vertices, components=[0, 1]) for loop in range(3): # The same parametrization: the fixed values are read at each call result = pysolvegn.solve([correlation.term], fixed.reparametrized_pack(), parametrization=fixed.parametrization, max_iteration=20) fixed.reparametrized_apply(result.parameters)
Instantiation and new parametrizations#
A SDICFixedParametrization is created with the unknowns of the problem (the same
pysdic.SDICUnknowns as its terms), the selected vertices and components. The values that are not selected
are read from the analysis at each call: after a convergence written in the analysis, the same parametrization
can be used again. It is immutable: the methods below create a new parametrization.
|
A new parametrization with other unknowns and the same selection (vertices, components). |
|
A new parametrization with other options ( |
Reduced vector#
The solver optimizes the reduced vector \(\vec{q}\) (the selected entries of \(\vec{p}\), total values):
Warning
With a parametrization, always use SDICFixedParametrization.reparametrized_pack(),
SDICFixedParametrization.reparametrized_unpack() and SDICFixedParametrization.reparametrized_apply()
on the vectors of the solver. unknowns.pack, unknowns.unpack and unknowns.apply work on the complete
vector \(\vec{p}\): giving them \(\vec{q}\) raises an error (wrong size) or, worse, misplaces the values if
the sizes happen to match.
Without parametrization |
With a parametrization |
|---|---|
|
|
|
|
|
|
parametrization = SDICFixedParametrization(unknowns, vertices=vertices, components=[0, 1])
result = pysolvegn.solve([correlation.term], parametrization.reparametrized_pack(),
parametrization=parametrization.parametrization)
parametrization.reparametrized_apply(result.parameters) # NOT unknowns.apply(...)
The reduced vector \(\vec{q}\) of the current state of the analysis: the initial parameters |
|
Split a reduced vector \(\vec{q}\) (e.g. |
|
Write a reduced vector \(\vec{q}\) (e.g. |
|
The complete vector \(\vec{p} = P(\vec{q})\): the current values of the unknowns in the analysis, with the selected ones replaced by \(\vec{q}\). |
Attributes#
The |
|
The unknowns of the problem (the complete vector \(\vec{p}\)). |
|
The analysis of the problem (shared with its terms). |
|
The indices \(I\) of the selected unknowns in \(\vec{p}\) (read-only). |
|
The number of optimized unknowns \(\dim(\vec{q})\). |
|
Whether the Jacobian \(S\) is sparse. |