Added Total Noise output parsing for XYCE

This commit is contained in:
Vadim Kuznetzov 2016-06-21 17:44:22 +03:00
parent 1218d5baa0
commit 3fb0d30d57
4 changed files with 64 additions and 2 deletions

View File

@ -775,6 +775,47 @@ void AbstractSpiceKernel::parseXYCESTDOutput(QString std_file, QList<QList<doubl
}
}
/*!
* \brief AbstractSpiceKernel::parseXYCENoiseLog
* \param logfile
* \param sim_points
* \param var_list
*/
void AbstractSpiceKernel::parseXYCENoiseLog(QString logfile, QList<QList<double> > &sim_points,
QStringList &var_list)
{
var_list.clear();
var_list.append(""); // dummy indep var
var_list.append("ONOISE_TOTAL");
var_list.append("INOISE_TOTAL");
QString content;
QList <double> sim_point;
sim_point.append(0.0);
QFile ofile(logfile);
if (ofile.open(QFile::ReadOnly)) {
QTextStream ts(&ofile);
content = ts.readAll();
ofile.close();
}
QTextStream data(&content);
sim_points.clear();
while (!data.atEnd()) { // Parse header;
QString lin = data.readLine();
if (lin.startsWith("Total Output Noise")) {
double val = lin.section('=',1,1).toDouble();
sim_point.append(val);
}
if (lin.startsWith("Total Input Noise")) {
double val = lin.section('=',1,1).toDouble();
sim_point.append(val);
}
}
sim_points.append(sim_point);
}
/*!
* \brief AbstractSpiceKernel::parseResFile Extract sweep variable name and
* values from Ngspice or Xyce *.res output
@ -886,6 +927,9 @@ void AbstractSpiceKernel::convertToQucsData(const QString &qucs_dataset, bool xy
parseFourierOutput(full_outfile,sim_points,var_list,xyce);
} else if (ngspice_output_filename.endsWith(".txt_std")) {
parseXYCESTDOutput(full_outfile,sim_points,var_list,isComplex);
} else if (ngspice_output_filename.endsWith(".noise_log")) {
isComplex = false;
parseXYCENoiseLog(full_outfile,sim_points,var_list);
} else if (ngspice_output_filename.endsWith(".noise")) {
isComplex = false;
parseNoiseOutput(full_outfile,sim_points,var_list,hasParSweep);

View File

@ -91,6 +91,8 @@ public:
void parseXYCESTDOutput(QString std_file,
QList< QList<double> > &sim_points,
QStringList &var_list, bool &isComplex);
void parseXYCENoiseLog(QString logfile, QList< QList<double> > &sim_points,
QStringList &var_list);
void parseResFile(QString resfile, QString &var, QStringList &values);
void convertToQucsData(const QString &qucs_dataset, bool xyce = false);
QString getOutput();

View File

@ -35,6 +35,7 @@ Xyce::Xyce(Schematic *sch_, QObject *parent) :
{
simulator_cmd = QucsSettings.XyceExecutable;
Nprocs = QucsSettings.NProcs;
Noisesim = false;
}
/*!
@ -274,8 +275,20 @@ void Xyce::SaveNetlist(QString filename)
* execute the next simulation from queue.
*/
void Xyce::slotFinished()
{
output += SimProcess->readAllStandardOutput();
{
output += SimProcess->readAllStandardOutput();;
if (Noisesim) {
QFile logfile(workdir + QDir::separator() + "spice4qucs.noise_log");
if (logfile.open(QIODevice::WriteOnly)) {
QTextStream ts(&logfile);
ts<<output;
logfile.close();
}
Noisesim = false;
output_files.append("spice4qucs.noise_log");
}
if (netlistQueue.isEmpty()) {
emit finished();
emit progress(100);
@ -317,6 +330,7 @@ void Xyce::nextSimulation()
{
if (!netlistQueue.isEmpty()) {
QString file = netlistQueue.takeFirst();
if (file.endsWith(".noise.cir")) Noisesim = true;
SimProcess->setWorkingDirectory(workdir);
QString cmd = QString("%1 %2 \"%3\"").arg(simulator_cmd,simulator_parameters,file);
SimProcess->start(cmd);

View File

@ -33,6 +33,8 @@ class Xyce : public AbstractSpiceKernel
{
Q_OBJECT
private:
bool Noisesim;
unsigned int Nprocs;
QStringList simulationsQueue;
QStringList netlistQueue;