PODTrajectoryModule#
- class PODTrajectoryModule(time_grid, trajectories, n_modes, poly_order, additional_data=None, batch_size=None, is_periodic=False)[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.
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:
time_grid (
ndarray
) – (#time_steps)trajectories (
ndarray
) – (#particles, #time_steps, 3)n_modes (
int
) – Number of modes used for reduce-order representationpoly_order (
int
) – Order of the Taylor-series used to fit the mode-weightsadditional_data (
Dict
[str
,ndarray
]) – Dict[str, np.ndarray] of shape (#particles, #time_steps, #channels)batch_size (
int
) – intis_periodic (
bool
) –
Methods:
__call__
(initial_positions, timing[, ...])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
(particle_positions, dt, ...)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.
Together with self.current_batch_size determines the subset of particle trajectories that is evaluated on call and increment_particles
Allows to only evaluate the position for a batch of stored particle trajectories
Keeps track of the current timing when increment_particles is called.
Number of modes used for reduce-order representation
- __call__(initial_positions, timing, batch_index=0, **kwargs)[source]#
Reconstructs the data state at given times t, by evaluating the taylor series of mode-weights and computing the weighted sum.
- 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(particle_positions: ~tensorflow.python.framework.tensor.Tensor, dt: ~tensorflow.python.framework.tensor.Tensor, **kwargs) -> (<class 'tensorflow.python.framework.tensor.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:
particle_positions (
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), {k: v} - additional data
-
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.
-
end_time:
Variable
#
-
n_modes:
Variable
# Number of modes used for reduce-order representation
-
ref_time:
Variable
#