LTSpice_Simulator module
A Module responsible getting LTSpice simulation data as for verification. Ensure that ‘LTSpice_exe_Path’ in this file points to your LTspice installation. Requires the the LC interface spice file template ‘LC_Spice_Input.txt’ which must be in the root directory.
- LTSpice_Simulator.get_Spice_Arrays(**new_Spice_values)
Runs a LTSpice simulation on a Circuit theory LC interface as well as a distributed LC interface. Returns associated arrays. Useful for comparing distributed effects to lumped element effects, and the distributed soltuion made in using
Wavefront_Generation.Full_Cycle().- Parameters:
new_Spice_values – A set of key-value pairs used to configure the simulaiton. This dictonary is calculatedd on the creation of a
Wavefront_Storage.Data_Input_Storage,
storete under the parameter of SPICE_input_values. Default simulation values are as follows and will be overwritten with provided key-values.
new_Spice_values:
L_impedance (str) - The inductor impedance. Default is ‘100’.
L_time (str) - The inductor time constant. Default is ‘1’.
C_impedance (str) - The capacitor impedance. Default is ‘1’.
C_time (str) - The capacitor time constant. Default is ‘1’.
number_periods (str) - The number of periods to simulate. Default is ‘1’.
L_tot (str) - The total inductance. Default is ‘L_impedance*L_time/2 ‘.
C_tot (str) - The total capacitance. Default is ‘C_time/(2*C_impedance)’.
Simulation_stop_time (str) - The simulation stop time. Default is ‘2*number_periods*pi*sqrt(L_tot*C_tot)’.
Step_size (str) - The step size for the simulation. Default is ‘0.01’.
V_source (str) - The voltage of the source. Default is ‘1’.
Returns dictionary of output arrays [np.ndarrays]:
- dict{
“Time”,
“Inductor_Voltage_Circuit”,
“Inductor_Current_Circuit”,
“Capacitor_Voltage_Circuit”,
“Capacitor_Current_Circuit”,
“Inductor_Voltage_Tx”,
“Inductor_Current_Tx”,
“Capacitor_Voltage_Tx”,
“Capacitor_Current_Tx”
}
manual SPICE simulaitonfrom LTSpice_Simulator import get_Spice_Arrays import matplotlib.pyplot as plt # Do manual simulation # Change Impedances and simulaiton timestep LTSpice_Arrays = get_Spice_Arrays(L_impedance = '500',C_impedance = '20', Step_size='0.1') # Plot Inductor votlage using Lumped circuit elements plt.plot(LTSpice_Arrays['Time'],LTSpice_Arrays['Inductor_Voltage_Circuit']) plt.title('Lumped Element analysis of Inductor Voltage') plt.xlabel('time (s)') plt.ylabel('Voltage (V)') plt.show()
Using SPICE to verify outputfrom LTSpice_Simulator import get_Spice_Arrays from Wavefront_Generation import Full_Cycle from Wavefront_Plotting import plot_time_interconnect import matplotlib.pyplot as plt interface = Full_Cycle(L_impedance = '500',C_impedance = '20') # get spice kwarg array spice_kwargs = interface.data_input.SPICE_input_values # set step-size to be GCD/8 to be safe step_size = interface.data_input.GCD/8 # get arrays LTSpice_outputs = get_Spice_Arrays(**spice_kwargs,Step_size=str(step_size)) fig,ax = plt.subplots() # plot lumped current ax.plot(LTSpice_outputs['Time'],LTSpice_outputs['Capacitor_Current_Tx']) # plot distributed from LTSpice ax.plot(LTSpice_outputs['Time'],LTSpice_outputs['Capacitor_Current_Circuit']) # plot distributed from simulator plot_time_interconnect(interface.data_output_ordered,ax,'Current Capacitor',True) ax.legend(['LT-lumped','LT-dist','Wavefronts']) plt.show()
Warning
does not account for the lengths of the capacitor and inductor. Also only wokrs for LC osscialtor configuration with no load.