mirror of
https://github.com/ra3xdh/qucs_s
synced 2025-03-28 21:13:26 +00:00
Implemented auto-generarion netlist with ParSweep
This commit is contained in:
parent
5cfd2ccf80
commit
68a8af758e
@ -122,7 +122,7 @@ QString Param_Sweep::getNgspiceAfterSim()
|
||||
QString s;
|
||||
QString par = getProperty("Param")->Value;
|
||||
s = "set appendwrite\n";
|
||||
s += QString("echo \"$&number\" \"$&r_act\" >> spice4qucs.cir.res\n").arg(par);
|
||||
s += QString("echo \"$&number\" \"$&%1_act\" >> spice4qucs.cir.res\n").arg(par);
|
||||
s += QString("let %1_act = %1_act + delta\n").arg(par);
|
||||
s += "let number = number +1\n";
|
||||
s += "end\n";
|
||||
|
@ -359,7 +359,7 @@ void AbstractSpiceKernel::parseResFile(QString resfile, QString &var, QStringLis
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset)
|
||||
void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset, bool xyce)
|
||||
{
|
||||
QFile dataset(qucs_dataset);
|
||||
if (dataset.open(QFile::WriteOnly)) {
|
||||
@ -391,8 +391,11 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset)
|
||||
QString simstr = full_outfile;
|
||||
simstr.remove("_swp.txt");
|
||||
simstr = simstr.split('_').last();
|
||||
QString res_file = QDir::convertSeparators(workdir + QDir::separator()
|
||||
+ "spice4qucs." + simstr + ".cir.res");
|
||||
QString res_file;
|
||||
if (xyce) res_file = QDir::convertSeparators(workdir + QDir::separator()
|
||||
+ "spice4qucs." + simstr + ".cir.res");
|
||||
else res_file = QDir::convertSeparators(workdir + QDir::separator()
|
||||
+ "spice4qucs.cir.res");
|
||||
qDebug()<<res_file;
|
||||
parseResFile(res_file,swp_var,swp_var_val);
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
QList< QList<double> > &sim_points,
|
||||
QStringList &var_list, bool &isComplex);
|
||||
void parseResFile(QString resfile, QString &var, QStringList &values);
|
||||
void convertToQucsData(const QString &qucs_dataset);
|
||||
void convertToQucsData(const QString &qucs_dataset, bool xyce = false);
|
||||
QString getOutput();
|
||||
|
||||
|
||||
|
@ -144,7 +144,7 @@ void ExternSimDialog::slotProcessXyceOutput()
|
||||
// Set temporary safe output name
|
||||
QFileInfo inf(Sch->DocName);
|
||||
QString qucs_dataset = inf.canonicalPath()+QDir::separator()+inf.baseName()+"_xyce.dat";
|
||||
xyce->convertToQucsData(qucs_dataset);
|
||||
xyce->convertToQucsData(qucs_dataset,true);
|
||||
}
|
||||
|
||||
void ExternSimDialog::slotNgspiceStarted()
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "components/iprobe.h"
|
||||
#include "components/vprobe.h"
|
||||
#include "components/equation.h"
|
||||
#include "components/param_sweep.h"
|
||||
|
||||
Ngspice::Ngspice(Schematic *sch_, QObject *parent) :
|
||||
AbstractSpiceKernel(sch_, parent)
|
||||
@ -84,8 +85,20 @@ void Ngspice::createNetlist(QTextStream &stream, int NumPorts,
|
||||
qDebug()<<vars;
|
||||
|
||||
stream<<".control\n" //execute simulations
|
||||
<<"set filetype=ascii\n"
|
||||
<<"run\n";
|
||||
<<"set filetype=ascii\n";
|
||||
|
||||
bool hasParSWP = false;
|
||||
for(Component *pc = Sch->DocComps.first(); pc != 0; pc = Sch->DocComps.next()) {
|
||||
if (pc->Model==".SW") {
|
||||
if (!pc->Props.at(0)->Value.startsWith("DC")) {
|
||||
Param_Sweep *ParSWP = (Param_Sweep *)pc;
|
||||
stream<<ParSWP->getNgspiceBeforeSim();
|
||||
hasParSWP = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream<<"run\n";
|
||||
|
||||
QStringList vars_eq;
|
||||
QStringList Eqns;
|
||||
@ -122,12 +135,25 @@ void Ngspice::createNetlist(QTextStream &stream, int NumPorts,
|
||||
for (int i=0;i<Eqns.count();i++) {
|
||||
if (Eqns.at(i).contains(sim+".")) nods += " " + vars_eq.at(i);
|
||||
}
|
||||
QString filename = QString("%1_%2.txt").arg(basenam).arg(sim);
|
||||
|
||||
QString filename;
|
||||
if (hasParSWP) filename = QString("%1_%2_swp.txt").arg(basenam).arg(sim);
|
||||
else filename = QString("%1_%2.txt").arg(basenam).arg(sim);
|
||||
|
||||
QString write_str = QString("write %1 %2\n").arg(filename).arg(nods);
|
||||
stream<<write_str;
|
||||
outputs.append(filename);
|
||||
}
|
||||
|
||||
for(Component *pc = Sch->DocComps.first(); pc != 0; pc = Sch->DocComps.next()) {
|
||||
if (pc->Model==".SW") {
|
||||
if (!pc->Props.at(0)->Value.startsWith("DC")) {
|
||||
Param_Sweep *ParSWP = (Param_Sweep *)pc;
|
||||
stream<<ParSWP->getNgspiceAfterSim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream<<"exit\n"
|
||||
<<".endc\n";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user