create_test_case
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## 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