DutView
A Device Unter Test (DUT) can be single devices or full circuits and range from atomic TCAD simulations to full circuit simulations and also measurements. This range of different DUTs is represented in DMT as a view on a DUT. The name view is chosen, because sometimes the same device is measured and simulated in different simulators. So this “view-axis” can change, always the same are the DUT properties and also the data handling.
Submodules of DutView
Relation of the Submodules
![digraph "classes_dut" {
rankdir=BT
charset="utf-8"
"DMT.core.circuit.Circuit" [color="black", fontcolor="black", label="Circuit", shape="record", style="solid"];
"DMT.core.circuit.CircuitElement" [color="black", fontcolor="black", label="CircuitElement", shape="record", style="solid"];
"DMT.Hdev.DutHdev" [color="black", fontcolor="black", label="DutHdev", shape="record", style="solid"];
"DMT.core.DutCircuit" [color="black", fontcolor="black", label="DutCircuit", shape="record", style="solid"];
"DMT.core.DutMeas" [color="black", fontcolor="black", label="DutMeas", shape="record", style="solid"];
"DMT.ngspice.DutNgspice" [color="black", fontcolor="black", label="DutNgspice", shape="record", style="solid"];
"DMT.core.DutTcad" [color="black", fontcolor="black", label="DutTcad", shape="record", style="solid"];
"DMT.core.DutType" [color="black", fontcolor="black", label="DutType", shape="record", style="solid"];
"DMT.core.dut_type.DutTypeInt" [color="black", fontcolor="black", label="DutTypeInt", shape="record", style="solid"];
"DMT.core.DutView" [color="black", fontcolor="black", label="DutView", shape="record", style="solid"];
"DMT.xyce.DutXyce" [color="black", fontcolor="black", label="DutXyce", shape="record", style="solid"];
"enum.Enum" [color="black", fontcolor="black", label="Enum", shape="record", style="solid"];
"enum.Flag" [color="black", fontcolor="black", label="Flag", shape="record", style="solid"];
"DMT.core.MCard" [color="black", fontcolor="black", label="MCard", shape="record", style="solid"];
"DMT.core.mc_parameter.McParameterComposition" [color="black", fontcolor="black", label="McParameterComposition", shape="record", style="solid"];
"DMT.core.mc_parameter.McParameter" [color="black", fontcolor="black", label="McParameter", shape="record", style="solid"];
"DMT.Hdev.DutHdev" -> "DMT.core.DutTcad" [arrowhead="empty", arrowtail="none"];
"DMT.core.DutMeas" -> "DMT.core.DutView" [arrowhead="empty", arrowtail="none"];
"DMT.core.DutType" -> "enum.Flag" [arrowhead="empty", arrowtail="none"];
"DMT.core.MCard" -> "DMT.core.mc_parameter.McParameterComposition" [arrowhead="empty", arrowtail="none"];
"DMT.ngspice.DutNgspice" -> "DMT.core.DutCircuit" [arrowhead="empty", arrowtail="none"];
"DMT.xyce.DutXyce" -> "DMT.core.DutCircuit" [arrowhead="empty", arrowtail="none"];
"DMT.core.DutCircuit" -> "DMT.core.DutView" [arrowhead="empty", arrowtail="none"];
"DMT.core.DutTcad" -> "DMT.core.DutView" [arrowhead="empty", arrowtail="none"];
"enum.Flag" -> "enum.Enum" [arrowhead="empty", arrowtail="none"];
"DMT.core.dut_type.DutTypeInt" -> "DMT.core.DutType" [arrowhead="diamond", arrowtail="none", fontcolor="darkgreen", style="solid"];
"DMT.core.MCard" -> "DMT.core.circuit.CircuitElement" [arrowhead="diamond", arrowtail="none", fontcolor="darkgreen", label="parameters", style="solid"];
"DMT.core.mc_parameter.McParameterComposition" -> "DMT.core.circuit.CircuitElement" [arrowhead="diamond", arrowtail="none", fontcolor="darkgreen", label="parameters", style="solid"];
"DMT.core.mc_parameter.McParameter" -> "DMT.core.mc_parameter.McParameterComposition" [arrowhead="diamond", arrowtail="none", fontcolor="darkgreen", label="_paras", style="solid", taillabel="0..*"];
"DMT.core.circuit.CircuitElement" -> "DMT.core.circuit.Circuit" [arrowhead="diamond", arrowtail="none", fontcolor="darkgreen", label="netlist", style="solid", taillabel="0..*"];
"DMT.core.DutType" -> "DMT.core.DutView" [arrowhead="diamond", arrowtail="none", fontcolor="darkgreen", label="dut_type", style="solid"];
"DMT.core.circuit.Circuit" -> "DMT.core.DutCircuit" [arrowhead="diamond", arrowtail="none", fontcolor="darkgreen", label="_inp_circuit", style="solid"];
}](../_images/graphviz-9ea7fccaa3929107733ea15a464fbb891da458d8.png)
DutView class
- class DMT.core.dut_view.DutView(database_dir, name, dut_type, *, reference_node, copy_va_files=True, force=False, loading=False, separate_databases=False, list_copy=None, t_max=None, sim_dir=PosixPath('/root/.DMT/simulation_results'), simulate_on_server=None, simulator_command='', simulator_arguments=None, technology: Technology | None = None, width=None, length=None, nfinger=None, contact_config=None, flavor=None, ac_ports=None, nodes=None, inp_name=None, va_code_filter=None)[source]
Bases:
objectDutView is the parent class of all DUTs in DMT.
All simulation back-end classes must inherit from this class and overwrite the methods that raise NotImplemented errors. This ensures that all classes in DMT work independent of the concrete simulation back-end.
- Parameters:
- database_dir
strorNone The directory where all the databases of this project are saved. If None, DMT.config.DATA_CONFIG[“directories”][“database”] is used.
- name
str The name of the DutView object, which is used as a prefix for saving the database and the pickled object.
- dut_type
DutType Type of the DutView object, represented by a DutType object (basically an Enumeration).
- nodes[
str],optional List of names of the nodes of the DutView object. Only nodes that shall be present in the DutView’s database are relevant. They are past in the given order to all df methods which need the small-signal parameters.
- copy_va_files{
False,True},optional - force{
False,True},optional If True, all data found in the duts database are deleted.
- separate_databases{
False,True},optional If True, each simulation is saved in a separate database file and only the needed files are loaded. Usefull for large simulation files, like transient simulations. For small files, the lookup in the hard drive takes to long.
- list_copy[],
optional List of files or file contents to copy to the simulation directory as additional files.
- t_max
int,optional Maximum simulation duration for this dut. This value and the simulation controller value have to be exceeded.
- simulate_on_server{
False,True,None},optional If not set, the config value is used.
- simulator_command
str Command to start the correct circuit simulator
- simulator_arguments
list[str] List of arguments for the simulator command, will be added one by one before the input file.
- technology
Technology,optional - width
float64,optional Width in m.
- length
float64,optional Length in m.
- nfinger
int,optional Number of parallel emitter fingers
- contact_config
str,optional String describing the physical contact config for this device. The possible value depends on the technology, example: ‘CBEBC’.
- inp_name
str The name of the input file to be generated.
- database_dir
- Attributes:
- database_dir
str The directory where all the databases of this project are saved.
- name
str The name of the DutView object, which is used as a prefix for saving the database and the pickled object.
- manager
DatabaseManager The DatabaseManager object of the DutView, used to interact with its database.
- sim_folder
str Path to the simulation folder
- inp_name
str The name of the input file to be generated.
- save_dir
str This is the directory were the DutView object will save its object and database.
- dut_dir
str This is the directory were the DutView object will create its pickle file. This equals save_dir+’.h5’
- database_dir
str This is the directory were the DutView object will create its database. This equals save_dir+’.h5’
- dut_type
DutType Type of the DutView object, represented by a DutType object (basically an Enumeration).
- nodes[
str] List of names of the nodes of the DutView object. Only nodes that shall be present in the DutView’s database are relevant. They are past in the given order to all df methods which need the small-signal parameters.
- ac_ports[
str] List of ports for AC simulations. At each port mentioned here a AC source is applied. Defaults to the first 2 nodes.
- list_copy[
data] List of path or data to save to the simlation folder. If it is a path, the file is copied. If it is data, a file is created.
- database_dir
Methods
run_simulation(sweep)
Start the simulation of this DutView object.
prepare_simulation(sweep)
Prepare a simulation folder and run make_input().
make_input(sweep)
Create the correct simulation input file from this Dut_view together with a Sweep object.
get_hash()
Return a unique hash for this Dut without considering the Sweep.
save()
Save this DutView as a pickled .p file to save_dir.
__getstate__()
This helper methods helps in the pickling process.
__setstate__(state)
This helper methods helps in the pickling process.
load_dut(save_dir)
Static class method. Loads a DutView object from a pickle file with full path save_dir.
add_data(df, key, force=True)
Add data into the DutView’s database.
get_data(key)
Get the data stored in key from the DutView’s database.
check_existence_sweep(self, sweep)
Returns True if the simulation corresponding to this DutView object in combination with Sweep object sweep has already been run.
del_db()
Delete the DutView’s database.
clean_all_data()
Iterate through all keys in the DutView’s database and try to clean the column names according to the internal DMT format.
- add_data(data: DataFrame | Sweep | str | os.Pathlike, key: str | None = None, force: bool = True, validate: bool = True, **kwargs)[source]
Add a measurement or simulation data to the DutView’s data.
- Parameters:
- data
DataFrame,sweeporstr If DataFrame: Directly added to the data using the given key. If str: Full path to the file that shall be added to the database if sweep: Simulated sweep to import.
- key
str,optional Key that shall be used in the database to save the data.
- forcebool,
optional Default=True. If = True, the data is added even if it already exists.
- kwargs
keywordarguments,optional Passed on to read_data in case of str as a data argment.
- data
- check_existence_sweep(sweep: Sweep)[source]
Return true, if the combination dut+sweep has already been simulated.
If self.data is None, the database is loaded first.
- Parameters:
- sweep
DMT.core.sweep.Sweep Sweep object that can return a hash.
- sweep
- Returns:
- existencebool
Is True if the combination dut+sweep has already been simulated.
- clean_data(fallback=None, **kwargs)[source]
Clean the dataframe columns of the DataFrame objects in this DutMeas objects database.
- Parameters:
- fallback
dict,optional Is used to update self.nodes_fallback for this special key to clean.
- fallback
- property data[source]
data is a property to ensure loading before usage.
As _data is a dict, the getter is also called before setting. So the separate setter is not necessary. If someone tries to set dut.data an attribute error occurs, but setting dict entries is possible directly.
- delete_sim_results(sweep: Sweep, ignore_errors=False)[source]
Deletes the simulation results of the given sweep.
- classmethod from_json(json_content: Dict, classes_technology: List[Type[Technology]], subclass_kwargs: Dict | None = None) DutView[source]
Static class method. Loads a DutView object from a pickle file with full path save_dir.
- Parameters:
- json_content
dict Readed dictionary from a saved json DutView.
- classes_technology
List[Type[Technology]] All possible technologies this loaded DutView can have. One will be choosen according to the serialized technology loaded from the file.
- subclass_args: List = None,
Positional arguments needed
- subclass_kwargs: Dict = None,
- json_content
- Returns:
DutViewLoaded object.
- get_data(key: str = 'iv', sweep: Sweep | None = None) DataFrame[source]
Return data stored in the DutView’s data.
One needs to specify either:
key : The data stored under the path key in the dut’s database is returned.
sweep : Get the data from this sweep. If none, key must be a valid key for the database.
sweep+key: Return the data stored as self.get_sweep_key(sweep)+’/’+key from the dut’s database.
- Parameters:
- key
str,optional, {‘iv’} The key of the data in the DutView’s database that shall be retrieved.
- sweep
DMT.core.sweep.Sweep,optional The sweep whose data shall be looked for.
- key
- get_db_dir(name='db') Path[source]
Returns the name for a db, either use ‘db’ for regular behavior or use ‘sweep.get_hash()’ for a db per sweep.
- get_hash()[source]
Return a unique hash for this Dut without (!) considering the Sweep.
- Returns:
- hash
float64 Hash that corresponds to this DUT.
- hash
- get_key_temperature(key)[source]
Function that returns the temperature of a given data key. Overwrite this if the measurements differ from the default DMT naming.
Default naming is:
Single temperature: “Txxx.xxK”
List of temperatures: “T(xxx.xx,yyy.yy,…)K”
Range of temperatures: “T[xxx.xx-sss.ss-yyy.yy]K”, s is the step
- get_sim_folder(sweep: Sweep) Path[source]
Returns the simulation folder of the given sweep
- Parameters:
- sweep
Sweep Sweep object that corresponds to the folder.
- sweep
- Returns:
strPath to the simulationfolder
- import_output_data(sweep, delete_sim_results=False)[source]
Read the output files that have been produced while simulating sweep and attach them to self.db.
- Parameters:
- sweep
DMT.core.sweep.Sweep Sweep that has been simulated for the desired output files.
- delete_sim_results{
False,True},optional If True, the simulation folder is deleted after reading.
- sweep
- Raises:
NotImplementedErrorIf the Dut is not a simulatable dut.
IOErrorIf the given sweep can not be read.
- info_json(**_kwargs) Dict[source]
Returns a dict with serializeable content for the json file to create.
Add the info about the concrete subclass to create here! See :py:method::DMT.core.dut_meas.DutMeas.info_json() for an example implementation.
- Returns:
dictserialized dictionary ready to be dumped to json.
- load_db(sweep=None)[source]
Load saved data from the database into the object.
If the complete dictionary is reloaded, here it is set directly to self._data. if separate databases is activated it loads only the given sweep (and it has to be given then!)
- static load_dut(file_dut, classes_technology: List[Type[Technology]] | None = None, classes_dut_view: List[Type[DutView]] | None = None) DutView[source]
Static class method. Loads a DutView object from a pickle file with full path save_dir.
- Parameters:
- file_dut
stroros.Pathlike Path to the json or pickle DutView file that shall be loaded.
- classes_technology
List[Type[Technology]] All possible technologies this loaded DutView can have. One will be choosen according to the serialized technology loaded from the file.
- classes_dut_view
List[Type[DutView]] All possible DutViews this loaded DutView can be. One will be choosen according to the serialized dutview class name loaded from the file.
- file_dut
- Returns:
DutViewLoaded object.
- make_input(sweep: Sweep)[source]
Joins simulation header with a given Sweep object and returns it.
- Parameters:
- sweep
DMT.core.sweep.Sweep Sweep specification according to the Sweep class.
- sweep
- make_pbs(sweep)[source]
Create a PBS script for the PBS job system. (See: https://albertsk.files.wordpress.com/2011/12/pbs.pdf)
- prepare_simulation(sweep: Sweep)[source]
Creates a simulation folder, appends the sweep to the structure definition and creates a input file in the simulation folder.
- Parameters:
- sweep
Sweep
- sweep
- remove_data(key: str)[source]
Remove a measurement or simulation dataframe from the DutView’s data.
- Parameters:
- key
str Key that shall be removed from the database.
- key
- save(**kwargs)[source]
Save this DutView as a json file and the also the data into the database on the hard drive. The kwargs are passed on to :py:method::DMT.core.dut_view.DutView.info_json() or the overwritten method.
- save_db(sweep_keys=None, sweeps=None)[source]
Write a database for this dut. If it already exists it is overwritten. Does NOT save all keys starting with ‘_’
- validate_simulation_successful(sweep: Sweep)[source]
Checks if the simulation of the given sweep was successful.
- Parameters:
- sweep
DMT.core.sweep.Sweep Sweep that has been simulated.
- sweep
- Raises:
NotImplementedErrorIf the Dut is not a simulatable dut.
SimulationUnsuccessfulIf the simulation output is not valid.
FileNotFoundErrorIf the sim log file does not exist.