Temporal Reconstruction from Dynamic Mode Decomposition

Description

Computes the temporal evolution of modes from a DMD decomposition of a given input Base.

Construction

import antares
myt = antares.Treatment('DmdtoTemporal')

Parameters

  • base: antares.Base

    The input base resulting from a DMD treatment. (or has the same structure)

  • base_mesh: antares.Base

    The input base containing the mesh of the domain (used in the DMD treatment). This base must only contain one zone.

  • time_step: float

    Constant time step between snapshots (used in the DMD treatment).

  • nb_instant: float

    Number of snapshots in the base used for the dmd. the same number are reconstructed.

  • list_modes: list(int), default= []

    The number of the modes that have to be reconstructed in time. Each mode is reconstructed one after the other. The output base will contain one zone for each given mode in list_modes with nb_instant instants in each zone.

  • sum_modes: bool, default= False

    Sum the modes or not.

    If False, the output base will contain the instants coming from each mode of the list_modes. If True, it will only contain the instant for the sum of the modes.

  • dimension: str, default= 2d_3d

    Type of the DMD performed beforehand.

    • 1d: Treatment(‘dmd1d’)

    • 2d_3d: Treatment(‘dmd’)

  • variables: list(str), default= []

    The variable names considered for the temporal reconstruction.

  • temporal_amplification: bool, default= True

    Variables to perform the temporal reconstruction. Into DMD approach, a temporal amplification term can be accounted for conversely to classical FFT approaches. In numerical simulations for steady regimes, since the extraction time is generally sparse, the amplification term can be different than zero for periodic phenomena which is generally to be avoided and it is so advised to turn off this term. However, when looking at transient phenomena, this term can be activated.

Preconditions

The input base base must be issued from the DMD treatments (dmd1d, dmd).

The input base base_mesh must only contain one zone.

Postconditions

The output base contains the coordinates of base_mesh and the instants that have been reconstructed.

Example

import antares
myt = antares.Treatment('DmdtoTemporal')
myt['base'] = dmd_base
myt['base_mesh'] = mesh_base
myt['list_modes'] = [1, 2]
myt['sum_modes'] = True
myt['nb_instant'] = 4
myt ['time_step'] = 1e-4
myt ['variables'] = ['rhovx', 'rhovy', 'rhovz', 'rhoE']
output_base = myt.execute()

Main functions

class antares.treatment.TreatmentDmdtoTemporal.TreatmentDmdtoTemporal
execute()

Computes the temporal evolution of modes.

Returns

The base with reconstructed instants.

Return type

antares.Base

Example

"""
This example illustrates the reconstruction of temporal
snapshots for modes (Dynamic Mode Decomposition)
of a 2D signal.
"""
import os
if not os.path.isdir('OUTPUT'):
    os.makedirs('OUTPUT')

import antares
import numpy as np

# ------------------
# Read the files
# ------------------
r = antares.Reader('bin_tp')
r['filename'] = os.path.join('..', 'data', 'CAVITE', 'DMD_CUTS', 'cut_y_ite<instant>')
r['instant_step'] = 2
base = r.read()
# 3D base with flowfield

base.compute_cell_volume()

# put values at node location
base.cell_to_node()

# only keep node values
base = base.get_location('node')

# keep only one zone
merge = antares.Treatment('merge')
merge['base'] = base
base = merge.execute()

# keep a base with 3D coordinates
base_mesh = base[:, :, (('x','node'),('y','node'),('z','node'))]

# remove coordinates for DMD treatment
del base[:, :, (('x', 'node'), ('y', 'node'), ('z', 'node'))]

# get modes
treatment = antares.Treatment('Dmd')
treatment['time_step'] = 4e-4
treatment['noiselevel'] = 1e-5
treatment['base'] = base
treatment['type'] = 'mod/phi'
treatment['variables'] = ['cell_volume', 'rovx', 'rovy', 'rovz', 'roE']
result = treatment.execute()

# reconstruct time evolution for two modes
treatment = antares.Treatment('DmdtoTemporal')
treatment['base'] = result
treatment['base_mesh'] = base_mesh
treatment['list_modes'] = [1, 2]
treatment['sum_modes'] = True
treatment['nb_instant'] = len(base[0].keys())
treatment['time_step'] = 1e-4
treatment['variables'] = ['rovx', 'rovy', 'rovz', 'roE']
base_time = treatment.execute()

base_time.show()

w = antares.Writer('bin_tp')
w['filename'] = os.path.join('OUTPUT', 'test_dmd2time.plt')
w['base'] = base_time
w.dump()