Implemented Pole/Zero analysis with parameter sweep support

This commit is contained in:
Vadim Kuznetzov 2015-11-08 14:10:56 +03:00
parent 59f2a59943
commit 0ac726a9bd
3 changed files with 23 additions and 5 deletions

View File

@ -77,7 +77,8 @@ QString SpicePZ::spice_netlist(bool isXyce)
if (!isXyce) {
s = QString("pz %1 %2 %3 %4\n").arg(Props.at(0)->Value).arg(Props.at(1)->Value)
.arg(Props.at(2)->Value).arg(Props.at(3)->Value);
s += QString("let dummy_var = 0.0\n"); // To overcome featurebug of Ngspice
s += "echo \"PZ analysis\" >> spice4qucs.cir.pz\n";
s += "let dummy_var = 0.0\n"; // To overcome featurebug of Ngspice
// when printing single variable
s += QString("print all >> spice4qucs.cir.pz\n");
} else {

View File

@ -453,18 +453,23 @@ void AbstractSpiceKernel::parsePZOutput(QString ngspice_file, QList<QList<double
else var = "pole";
var_list.clear();
var_list.append("");
sim_points.clear();
ParSwp = false;
QFile ofile(ngspice_file);
if (ofile.open(QFile::ReadOnly)) {
QTextStream ngsp_data(&ofile);
QStringList lines = ngsp_data.readAll().split("\n");
if (lines.count("PZ analysis")>1) ParSwp = true;
foreach (QString lin, lines) { // Extract poles
if (lin.contains(var + "(")) {
if (!var_list.contains(var)) var_list.append(var);
if (!var_list.contains(var)) {
var_list.append(var+"_number");
var_list.append(var);
}
QList <double> sim_point;
sim_point.append(0.0);
sim_point.append(lin.section('(',1,1).section(')',0,0).toDouble());
QString right = lin.section("=",1,1);
sim_point.append(right.section(",",0,0).toDouble());
sim_point.append(right.section(",",1,1).toDouble());
@ -685,6 +690,11 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset, bool xy
} else if (ngspice_output_filename.endsWith(".pz")) {
isComplex = true;
parsePZOutput(full_outfile,sim_points,var_list,hasParSweep);
if (hasParSweep) {
QString res_file = QDir::convertSeparators(workdir + QDir::separator()
+ "spice4qucs.pz.cir.res");
parseResFile(res_file,swp_var,swp_var_val);
}
} else if (ngspice_output_filename.endsWith("_swp.txt")) {
hasParSweep = true;
QString simstr = full_outfile;

View File

@ -136,7 +136,11 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
QString s2 = getParentSWPscript(pc,sim,true,hasDblSWP);
stream<<(s2+s);
hasParSWP = true;
} else if (SwpSim.startsWith("TR")&&(sim=="tran")) {
} else if (SwpSim.startsWith("PZ")&&(sim=="pz")) {
QString s2 = getParentSWPscript(pc,sim,true,hasDblSWP);
stream<<(s2+s);
hasParSWP = true;
} if (SwpSim.startsWith("TR")&&(sim=="tran")) {
QString s2 = getParentSWPscript(pc,sim,true,hasDblSWP);
stream<<(s2+s);
hasParSWP = true;
@ -266,6 +270,9 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
} else if (SwpSim.startsWith("NOISE")&&(sim=="noise")) {
s += getParentSWPscript(pc,sim,false,b);
stream<<s;
} else if (SwpSim.startsWith("PZ")&&(sim=="pz")) {
s += getParentSWPscript(pc,sim,false,b);
stream<<s;
} else if (SwpSim.startsWith("TR")&&(sim=="tran")) {
s += getParentSWPscript(pc,sim,false,b);
stream<<s;