## Draw a schematic using gschem gschem ## Create a netlist using gnetlist SCHEMATIC_NAME=$(ls *.sch) CIRCUIT_NAME="$(basename $SCHEMATIC_NAME .sch).cir" echo "gnetlist -g spice-sdb -o $CIRCUIT_NAME $SCHEMATIC_NAME" gnetlist -g spice-sdb -o $CIRCUIT_NAME $SCHEMATIC_NAME ## add the simulation parameters from the validation test case or otherwise echo "nedit *.cir ../RUN_DIRECTORY/*.cir" nedit *.cir ../RUN_DIRECTORY/*.cir ## run ngspice echo "ngspice < $CIRCUIT_NAME > test_circuit.dat" ngspice < $CIRCUIT_NAME > test_circuit.dat ## plot results against the analytic solution with gnuplot # COMPARE THE RESULTS OF THE SPICE MODEL AGAINST THE ANALYTIC MODEL USING GNUPLOT # read the analytic solution file header read HEADER < ../RUN_DIRECTORY/analytic_solution.dat if [ "$HEADER" = "#LOG_FREQUENCY_DATA" ]; then # create an input file for gnuplot: Log frequency plot echo "set xlabel 'Frequency(Hz)' set ylabel 'V(f)' set logscale x plot '../RUN_DIRECTORY/analytic_solution.dat' u 1:2 title 'Analytic solution' w p lc 2,\ 'test_circuit.dat' u 2:3 title 'Spice subcircuit test solution' w l lc 1 pause -1 " > plot.plt elif [ "$HEADER" = "#LIN_FREQUENCY_DATA" ]; then # create an input file for gnuplot: Linear frequency plot echo "set xlabel 'Frequency(Hz)' set ylabel 'V(f)' plot '../RUN_DIRECTORY/analytic_solution.dat' u 1:2 title 'Analytic solution' w p lc 2,\ 'test_circuit.dat' u 2:3 title 'Spice subcircuit test solution' w l lc 1 pause -1 " > plot.plt elif [ "$HEADER" = "#TIME_DOMAIN_DATA" ]; then # create an input file for gnuplot: time domain plot echo "set xlabel 'Time(s)' set ylabel 'V(t)' plot '../RUN_DIRECTORY/analytic_solution.dat' u 1:2 title 'Analytic solution' w p lc 2,\ 'test_circuit.dat' u 2:3 title 'Spice subcircuit test solution' w l lc 1 pause -1 " > plot.plt else echo "Error reading analytic solution header :$HEADER" exit 1 fi gnuplot plot.plt