Reference¶
Functions¶
- fbespice.read_raw(fn: str, simid: None | RawResID = None) dict[RawResID, DataFrame]¶
Read the SPICE raw data from file fn.
- Parameters:
fn – raw results file name.
simid – if None return all simulations in the file. Otherwise return the indicated simulation. simid must be a value of the enumeration RawResID. If the file includes multiple results of type simid, the first one is returned.
- Returns:
A
dictmappingfbespice.RawResIDto simulations results in the file. The simulation data is apandas.DataFramewhose columns are the SPICE variables stored in the file.
Both, the types of simulation results and the variables in each, can be obtained with the standard dictionary/DataFrame methods.
Example
>>> sim = read_raw("results.raw") >>> f = sim[RawResID.AC]['frequency'] >>> vop = sim[RawResID.AC]['v(vop)']
- fbespice.read_xyce(fn: str, stpfile: str | None = None) DataFrame¶
Read the ASCII result file produced by Xyce in STD mode.
- Parameters:
fn – file name
stpfile – when performing a .step SPICE simulation it should be a string with the name of the auxiliary Xyce result file (.res). Its content (swept parameters, …) will also be read and combined with simulation results.
- Returns:
Since Xyce currently can only run one simulation type at a time, this function doesn’t return a dictionary indexed by simulation type as
read_raw(), but directly apandas.DataFramewhose columns are the simulation vectors printed to the output file (with SPICE .print commands), plus optionally the content of the auxiliary result file.
Class Objects¶
- class fbespice.Xyce(design: str, exec_name: str = 'Xyce', exec_options: list = ['-quiet'], netlist_ext: str = 'cir', meta_netlist_ext: str = 'mcir', step_ext: str = 'res')¶
Create a Xyce object with all parameters to simulate a design.
Manage Xyce simulations, from netlist creation to reading results. All results files are stored in the same directory as the design file.
- Parameters:
design – a string with the path to the (meta-) netlist file to be simulated without extension.
exec_name – the Xyce program name (the full path if not on PATH).
exec_options – options to pass to Xyce on top of the netlist name.
netlist_ext – the extension of the netlist file (without dot).
meta_netlist_ext – the extension of the meta-netlist file (without dot).
step_ext – the extension of the auxiliary file produced by Xyce in SPICE .step simulations (without dot).
- netlist_from_meta(sim_vars: dict[str, Any])¶
Convert the meta-netlist into a simulable netlist.
- Parameters:
sim_vars – Mapping of meta-variable names to values.
- read_results(resid: XyceResID, step: bool = False) DataFrame¶
Read the simulation results.
- Parameters:
resid – define the simulation result file to read (the result file name is simulation type dependent).
step – set to
Trueif the simulation includes a SPICE .step command.
- Returns:
a
pandas.DataFramwith columns named after the stored simulation variables (seeread_xyce()).
- run()¶
Run the simulation.
- property design¶
- property exec_name¶
- property exec_options¶
- property meta_netlist_ext¶
- property netlist_ext¶
- property results_ext¶
- property step_ext¶
- class fbespice.NGSpice(design: str, exec_name: str = 'ngspice', exec_options: list = ['-b'], netlist_ext: str = 'cir', meta_netlist_ext: str = 'mcir', results_ext: str = 'raw')¶
Create a NGSpice object with all parameters to simulate a design.
Create objects to Manage ngspice simulations, from netlist creation to reading results. All results file are stored in the same directory as the design file.
- Parameters:
design – a string with the path to the (meta-) netlist file to be simulated without extension.
exec_name – the ngspice program name (the full path if not on PATH).
exec_options – options to pass to ngspice on top of the netlist name. Note that the option “-r” always implicitly added to produce results in the raw data format.
netlist_ext – the extension of the netlist file (without dot).
meta_netlist_ext – the extension of the meta-netlist file (without dot).
results_ext – the extension to be used for the raw result file produced by ngspice (without dot).
- netlist_from_meta(sim_vars: dict[str, Any])¶
Convert the meta-netlist into a simulable netlist.
- Parameters:
sim_vars – Mapping of meta-variable names to values.
- read_results(resid: RawResID | None = None) dict¶
Read the results of the simulation (raw file).
- Parameters:
resid – Define the simulation result type to read. ‘Note’ to read all results.
- Returns:
dictmappingfbespice.RawResIDto simulations results in the file. The simulation data is apandas.DataFramewhose columns are the SPICE variables stored in the file (seefbespice.read_raw()).
- run()¶
Run the simulation.
- property design¶
- property exec_name¶
- property exec_options¶
- property meta_netlist_ext¶
- property netlist_ext¶
- property results_ext¶
- property step_ext¶
Enumeration Objects¶
- class fbespice.RawResID(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
- AC = 'ac'¶
- DC = 'dc'¶
- DISTO2 = 'disto2'¶
- DISTO3 = 'disto3'¶
- NOISE = 'noise'¶
- NOISE_INT = 'noise_int'¶
- OP = 'op'¶
- PZ = 'pz'¶
- SENS = 'sens'¶
- SP = 'sp'¶
- TF = 'tf'¶
- TRAN = 'tran'¶
- class fbespice.XyceResID(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
- AC = 'ac'¶
- AC_IC = 'ac_ic'¶
- AC_SENS = 'ac_sens'¶
- DC = 'dc'¶
- DC_SENS = 'dc_sens'¶
- ES = 'es'¶
- HB = 'hb'¶
- HB_IC = 'hb_ic'¶
- HB_STARTUP = 'hb_startup'¶
- HB_TD = 'hb_td'¶
- NOISE = 'noise'¶
- TRAN = 'tran'¶
- TRAN_ADJ = 'tran_adj'¶
- TRAN_SENS = 'tran_sens'¶