generate_snapshot#

TwinModel.generate_snapshot(rom_name, on_disk=True, named_selection=None)#

Generate a field snapshot based on current states of the Twin, either in memory or on disk, for the full field or a specific part. It returns the field data as an array if in memory, or the path of the snapshot written on disk.

Parameters:
rom_namestr

Name of the TBROM considered to generate the snapshot.

on_diskbool

Whether the snapshot file is saved on disk (True which is the default) or returned in memory (False).

named_selectionstr (optional)

Named selection on which the snasphot has to be generated.

Returns:
str | np.ndarray

Path to snapshot written to disk if on_disk == True, else array of snapshot field data

Raises:
TwinModelError:

If TwinModel object has not been initialized. If rom_name is not included in the Twin’s list of TBROM If TBROM hasn’t its mode coefficients outputs connected to the twin’s outputs. If name_selection is not included in the TBROM’s list of Named Selections

Examples

>>> from pytwin import TwinModel
>>> # Instantiate a twin model, initialize it, and evaluate it step by step until you want to save its state
>>> model1 = TwinModel('model.twin')
>>> model1.initialize_evaluation()
>>> romname = model1.tbrom_names[0]
>>> nslist = model1.get_named_selections(romname)
>>> fieldresults = model1.generate_snapshot(romname, False, nslist[0])