PODTrajectoryModule#
- class PODTrajectoryModule(time_grid, data, n_modes, poly_order)[source]#
Captures the trajectories of an arbitrary set of particles (e.g. Nodes of structured meshes) by computing the proper orthogonal decomposition (POD) from a set of snapshots.
\[u(t) = \Sigma_j^{N_{modes}} \phi_j w_j(t),\]where \(\phi_j\) are the computed basis functions (modes) $w_j(t)$ are the corresponding mode-weights as function of time. To allow the motion state to be reconstructed from the low-rank representation at arbitrary time-points within the interval of specified snapshots, the mode-weights are represented as Taylor-series.
The use of this module is not limited to represent trajectories only is generalized to any set vectors, e.g. mesh node position combined with a local basis resulting in input-shapes (per snapshot) of (#particles, 3+3+3+3).
Example Usage:
data, t = ... # get snapshots of states and corresponding time-points # Shapes: data.shape == (#particles, #snapshots, #channels) # t.shape == (#steps, ) pod_module = cmrsim.trajectory.PODTrajectoryModule(data, t, n_modes=5, poly_oder=8) new_time_grid = np.linspace(t[0].m, t[-1].m, 100).astype(np.float32) reconstructed_states, _ = pod_module(new_time_grid) ## reconstructed_states.shape == (#particles, 100, #channels)
- Parameters:
Methods:
__call__
(timing, **kwargs)Reconstructs the data state at given times t, by evaluating the taylor series of mode-weights and computing the weighted sum.
calculate_pod
(time_grid, data, n_modes[, ...])Computes the proper orthogonal decomposition of data snapshots at points defined in time_grid.
increment_particles
(r, dt, **kwargs)Evaluates the particle position for the time self.current_time_ms + dt and adds the delta t to the current_time_ms variable
Attributes:
Computed basis-functions (modes) \(\phi_j\) used to represent the input data in a reduced order.
Number of modes used for reduce-order representation
- __call__(timing, **kwargs)[source]#
Reconstructs the data state at given times t, by evaluating the taylor series of mode-weights and computing the weighted sum.
- Parameters:
timing (
Tensor
) – (#timesteps) in milliseconds- Return type:
(
Tensor
,dict
)- Returns:
(#particles, #timesteps, self._channels), {}
- static calculate_pod(time_grid, data, n_modes, remove_mean=False)[source]#
Computes the proper orthogonal decomposition of data snapshots at points defined in time_grid. Returns only the n_modes number of most significant modes
- Parameters:
- Return type:
- Returns:
POD base modes, shape: (#particles * #channels, n_modes),
scaling of modes per time-step (#time_steps, n_modes)
- increment_particles(r: ~tensorflow.python.framework.ops.Tensor, dt: ~tensorflow.python.framework.ops.Tensor, **kwargs) -> (<class 'tensorflow.python.framework.ops.Tensor'>, <class 'dict'>)[source]#
Evaluates the particle position for the time self.current_time_ms + dt and adds the delta t to the current_time_ms variable
- Parameters:
r (
Tensor
) – unused parameter (to adhere to calling signature of trajectory modules)dt (
Tensor
) – temporal step lengthskwargs – unused parameter (to adhere to calling signature of trajectory modules)
- Return type:
(
Tensor
,dict
)- Returns:
(#batch, self._channels), {}
- basis_function: Variable#
Computed basis-functions (modes) \(\phi_j\) used to represent the input data in a reduced order. Shape (#particles * #channels, #modes)
- batch_size: Variable#
Together with self.current_batch_size determines the subset of particle trajectories that is evaluated on call and increment_particles
- current_batch_idx: Variable#
Allows to only evaluate the position for a batch of stored particle trajectories
- current_time_ms: Variable#
Keeps track of the current timing when increment_particles is called.
- n_modes: Variable#
Number of modes used for reduce-order representation
- optimal_parameters: Variable#
Stores the result of fitting the TaylorPolynomial for all particle trajectories
- order: Variable#
Stores the order of the TaylorPolynomial, defined on instantiation