flex_rf.tidy3d.SimulationData
Type: class │ Base(s): AbstractYeeGridSimulationData
Description
Section titled “Description”Stores data from a collection of Monitor objects in a Simulation.
The SimulationData objects store a copy of the original Simulation:, so it can be recovered if the
SimulationData is loaded in a new session and the Simulation is no longer in memory.
More importantly, the SimulationData contains a reference to the data for each of the monitors within the
original Simulation. This data can be accessed directly using the name given to the monitors initially.
Example(s)
Section titled “Example(s)”Standalone example:
import tidy3d as tdnum_modes = 5x = [-1,1,3]y = [-2,0,2,4]z = [-3,-1,1,3,5]f = [2e14, 3e14]coords = dict(x=x[:-1], y=y[:-1], z=z[:-1], f=f)grid = td.Grid(boundaries=td.Coords(x=x, y=y, z=z))scalar_field = td.ScalarFieldDataArray((1+1j) * np.random.random((2,3,4,2)), coords=coords)field_monitor = td.FieldMonitor( size=(2,4,6), freqs=[2e14, 3e14], name='field', fields=['Ex'], colocate=True,)sim = td.Simulation( size=(2, 4, 6), grid_spec=td.GridSpec(wavelength=1.0), monitors=[field_monitor], run_time=2e-12, sources=[ td.UniformCurrentSource( size=(0, 0, 0), center=(0, 0.5, 0), polarization="Hx", source_time=td.GaussianPulse( freq0=2e14, fwidth=4e13, ), current_amplitude_definition="total", ) ],)field_data = td.FieldData(monitor=field_monitor, Ex=scalar_field, grid_expanded=grid)sim_data = td.SimulationData(simulation=sim, data=(field_data,))To save and load the SimulationData object.
sim_data.to_file(fname='path/to/file.hdf5') # Save a SimulationData object to a HDF5 filesim_data = SimulationData.from_file(fname='path/to/file.hdf5') # Load a SimulationData object from a HDF5 file.Optionally, the simulation data can be loaded in a lazy mode, which only holds a reference until a field is accessed or a method is applied. This is useful to save I/O operations and memory.
sim_data = SimulationData.from_file(fname='path/to/file.hdf5', lazy=True) # Does not contain data until accessed.Parameters
Section titled “Parameters”simulation [Simulation] |
|
Original |
data [tuple[discriminated_union(MonitorDataType), ...]] |
|
List of |
log [str | None] = None |
|
A string containing the log information from the simulation run. |
diverged [bool] = False |
|
A boolean flag denoting whether the simulation run diverged. |
Attributes
Section titled “Attributes”final_decay_value [float] |
|
Returns value of the field decay at the final time step. |
Methods
Section titled “Methods”field_decay() |
|
Returns a TimeDataArray of field decay values over time steps. |
renormalize(normalize_index: int) |
|
Return a copy of the |
source_spectrum(source_index: int) |
|
Get a spectrum normalization function for a given source index. |