combine 2 xyce option

This commit is contained in:
Krasilnikov Sergey 2023-06-05 23:52:53 +03:00
parent b4519bdec0
commit ea517237a2
14 changed files with 98 additions and 115 deletions

View File

@ -125,13 +125,12 @@ int SP_Sim::getSPortsNumber()
QStringList SP_Sim::getExtraVariables()
{
switch (QucsSettings.DefaultSimulator) {
case spicecompat::simNgspice:
return getNgspiceExtraVariables();
case spicecompat::simXycePar:
case spicecompat::simXyceSer:
return getXyceExtraVariables();
default:
return QStringList();
case spicecompat::simNgspice:
return getNgspiceExtraVariables();
case spicecompat::simXyce:
return getXyceExtraVariables();
default:
return QStringList();
}
}

View File

@ -827,18 +827,22 @@ void DiagramDialog::slotReadVarsAndSetSimulator(int)
QFileInfo Info(defaultDataSet);
QString DocName = ChooseData->currentText()+".dat";
QString curr_sim;
QString curr_sim; // spicecompat::getDefaultSimulatorName(QucsSettings.DefaultSimulator); TODO ZERGUD
switch (QucsSettings.DefaultSimulator) {
case spicecompat::simQucsator: curr_sim = "Qucsator";
break;
case spicecompat::simNgspice: curr_sim = "Ngspice";
break;
case spicecompat::simXyceSer:
case spicecompat::simXycePar: curr_sim = "Xyce";
break;
case spicecompat::simSpiceOpus: curr_sim = "SpiceOpus";
break;
default: curr_sim = ChooseSimulator->currentText();
case spicecompat::simQucsator:
curr_sim = "Qucsator";
break;
case spicecompat::simNgspice:
curr_sim = "Ngspice";
break;
case spicecompat::simXyce:
curr_sim = "Xyce";
break;
case spicecompat::simSpiceOpus:
curr_sim = "SpiceOpus";
break;
default:
curr_sim = ChooseSimulator->currentText();
}
// Recreate items of ChooseSimulator. Only existing datasets

View File

@ -291,9 +291,7 @@ void AbstractSpiceKernel::createSubNetlsit(QTextStream &stream, bool lib)
header += "\n";
if (lib) stream<<"\n";
stream<<header;
bool xyce = false;
if ((QucsSettings.DefaultSimulator == spicecompat::simXyceSer)||
(QucsSettings.DefaultSimulator == spicecompat::simXycePar)) xyce = true;
bool xyce = QucsSettings.DefaultSimulator == spicecompat::simXyce;
startNetlist(stream,xyce);
stream<<".ENDS\n";
}
@ -486,8 +484,7 @@ void AbstractSpiceKernel::parseFourierOutput(QString ngspice_file, QList<QList<d
if (ss.endsWith(',')) ss.chop(1);
Nharm = ss.toInt();
while (!ngsp_data.readLine().contains(QRegularExpression("Harmonic\\s+Frequency")));
if (!(QucsSettings.DefaultSimulator == spicecompat::simXyceSer||
QucsSettings.DefaultSimulator == spicecompat::simXycePar)) lin = ngsp_data.readLine(); // dummy line
if (QucsSettings.DefaultSimulator != spicecompat::simXyce) lin = ngsp_data.readLine(); // dummy line
for (int i=0;i<Nharm;i++) {
lin = ngsp_data.readLine();
if (!firstgroup) {

View File

@ -120,7 +120,7 @@ void ExternSimDialog::slotSetSimulator()
ngspice->setSimulatorParameters(QucsSettings.SimParameters);
}
break;
case spicecompat::simXyceSer: {
case spicecompat::simXyce: {
xyce->setParallel(false);
connect(xyce,SIGNAL(started()),this,SLOT(slotNgspiceStarted()));
connect(xyce,SIGNAL(finished()),this,SLOT(slotProcessOutput()));
@ -129,19 +129,19 @@ void ExternSimDialog::slotSetSimulator()
xyce->setSimulatorParameters(QucsSettings.SimParameters);
}
break;
case spicecompat::simXycePar: {
#ifdef Q_OS_UNIX
xyce->setParallel(true);
#else
xyce->setParallel(false);
#endif
connect(xyce,SIGNAL(started()),this,SLOT(slotNgspiceStarted()));
connect(xyce,SIGNAL(finished()),this,SLOT(slotProcessOutput()));
connect(xyce,SIGNAL(errors(QProcess::ProcessError)),this,SLOT(slotNgspiceStartError(QProcess::ProcessError)));
connect(buttonSimulate,SIGNAL(clicked()),xyce,SLOT(slotSimulate()));
xyce->setSimulatorParameters(QucsSettings.SimParameters);
}
break;
// case spicecompat::simXycePar: {
//#ifdef Q_OS_UNIX
// xyce->setParallel(true);
//#else
// xyce->setParallel(false);
//#endif
// connect(xyce,SIGNAL(started()),this,SLOT(slotNgspiceStarted()));
// connect(xyce,SIGNAL(finished()),this,SLOT(slotProcessOutput()));
// connect(xyce,SIGNAL(errors(QProcess::ProcessError)),this,SLOT(slotNgspiceStartError(QProcess::ProcessError)));
// connect(buttonSimulate,SIGNAL(clicked()),xyce,SLOT(slotSimulate()));
// xyce->setSimulatorParameters(QucsSettings.SimParameters);
// }
// break;
case spicecompat::simSpiceOpus: {
xyce->setParallel(false);
connect(ngspice,SIGNAL(started()),this,SLOT(slotNgspiceStarted()),Qt::UniqueConnection);
@ -171,8 +171,7 @@ void ExternSimDialog::slotProcessOutput()
ext = ".dat.ngspice";
out = ngspice->getOutput();
break;
case spicecompat::simXycePar:
case spicecompat::simXyceSer:
case spicecompat::simXyce:
ext = ".dat.xyce";
out = xyce->getOutput();
break;
@ -200,15 +199,15 @@ void ExternSimDialog::slotProcessOutput()
//QString qucs_dataset = inf.canonicalPath()+QDir::separator()+inf.baseName()+"_ngspice.dat";
QString qucs_dataset = inf.canonicalPath()+QDir::separator()+inf.baseName()+ext;
switch (QucsSettings.DefaultSimulator) {
case spicecompat::simNgspice:
case spicecompat::simSpiceOpus:
ngspice->convertToQucsData(qucs_dataset);
break;
case spicecompat::simXycePar:
case spicecompat::simXyceSer:
xyce->convertToQucsData(qucs_dataset);
break;
default:break;
case spicecompat::simNgspice:
case spicecompat::simSpiceOpus:
ngspice->convertToQucsData(qucs_dataset);
break;
case spicecompat::simXyce:
xyce->convertToQucsData(qucs_dataset);
break;
default:
break;
}
emit simulated();
wasSimulated = true;
@ -219,17 +218,7 @@ void ExternSimDialog::slotProcessOutput()
void ExternSimDialog::slotNgspiceStarted()
{
editSimConsole->clear();
QString sim;
switch (QucsSettings.DefaultSimulator) {
case spicecompat::simNgspice: sim = "Ngspice";
break;
case spicecompat::simXyceSer: sim = "Xyce (serial) ";
break;
case spicecompat::simXycePar: sim = "Xyce (parallel) ";
break;
default: sim = "Simulator "; // Some other simulators could be added ...
break;
}
QString sim = spicecompat::getDefaultSimulatorName(QucsSettings.DefaultSimulator);
editSimConsole->insertPlainText(sim + tr(" started...\n"));
}
@ -246,17 +235,7 @@ void ExternSimDialog::slotNgspiceStartError(QProcess::ProcessError err)
QMessageBox::critical(this,tr("Simulate with SPICE"),msg,QMessageBox::Ok);
QString sim;
switch (QucsSettings.DefaultSimulator) {
case spicecompat::simNgspice: sim = "Ngspice";
break;
case spicecompat::simXyceSer: sim = "Xyce (serial) ";
break;
case spicecompat::simXycePar: sim = "Xyce (parallel) ";
break;
default: sim = "Simulator "; // Some other simulators could be added ...
break;
}
QString sim = spicecompat::getDefaultSimulatorName(QucsSettings.DefaultSimulator);
editSimConsole->insertPlainText(sim + tr(" error..."));
}
@ -281,17 +260,17 @@ void ExternSimDialog::slotSaveNetlist()
if (filename.isEmpty()) return;
switch (QucsSettings.DefaultSimulator) {
case spicecompat::simNgspice:
case spicecompat::simSpiceOpus: {
ngspice->SaveNetlist(filename);
case spicecompat::simNgspice:
case spicecompat::simSpiceOpus: {
ngspice->SaveNetlist(filename);
}
break;
case spicecompat::simXyceSer:
case spicecompat::simXycePar: {
xyce->SaveNetlist(filename);
break;
case spicecompat::simXyce: {
xyce->SaveNetlist(filename);
}
break;
default: break;
break;
default:
break;
}
if (!QFile::exists(filename)) {

View File

@ -354,22 +354,25 @@ bool spicecompat::check_nodename(QString &node)
return !nutmeg_keywords.contains(node);
}
QString spicecompat::getDefaultSimulatorName()
QString spicecompat::getDefaultSimulatorName(int simulator)
{
QString sim_lbl;
switch (QucsSettings.DefaultSimulator) {
case spicecompat::simQucsator: sim_lbl = QObject::tr("Qucsator");
break;
case spicecompat::simNgspice: sim_lbl = QObject::tr("Ngspice");
break;
case spicecompat::simSpiceOpus: sim_lbl = QObject::tr("SpiceOpus");
break;
case spicecompat::simXyceSer: sim_lbl = QObject::tr("Xyce (Serial)");
break;
case spicecompat::simXycePar: sim_lbl = QObject::tr("Xyce (Parallel)");
break;
default: sim_lbl = QObject::tr("Qucsator");
break;
QString result;
switch (simulator) {
case spicecompat::simQucsator:
result = QObject::tr("Qucsator");
break;
case spicecompat::simNgspice:
result = QObject::tr("Ngspice");
break;
case spicecompat::simSpiceOpus:
result = QObject::tr("SpiceOpus");
break;
case spicecompat::simXyce:
result = QObject::tr("Xyce");
break;
default:
result = QObject::tr("Qucsator");
break;
}
return sim_lbl;
return result;
}

View File

@ -4,6 +4,7 @@
#include <QString>
#include <QStringList>
#include <QRegularExpression>
#include "component.h"
/*!
\brief spicecompat namespace contains definitions responsible
@ -25,9 +26,16 @@ namespace spicecompat {
QString getSubcktName(const QString& subfilename);
QString convert_sweep_type(const QString& sweep);
bool check_nodename(QString &node);
QString getDefaultSimulatorName();
QString getDefaultSimulatorName(int simulator);
enum Simulator {simNgspice = 0, simXyceSer = 1, simXycePar = 2, simSpiceOpus = 3, simQucsator = 4, simNotSpecified=10};
enum Simulator : int {
simNotSpecified = 0b00000000,
simNgspice = 0b00000001,
simXyce = 0b00000010,
simSpiceOpus = 0b00000100,
simQucsator = 0b00001000,
simSpice = 0b00000111,
simAll = 0b11111111};
enum CMgen_mode {cmgenSUBifs = 0, cmgenEDDifs = 1, cmgenSUBmod = 2, cmgenEDDmod = 3};
}

View File

@ -444,7 +444,7 @@ int runNgspice(QString schematic, QString dataset)
int runXyce(QString schematic, QString dataset)
{
QucsSettings.DefaultSimulator = spicecompat::simXyceSer;
QucsSettings.DefaultSimulator = spicecompat::simXyce;
Schematic *sch = openSchematic(schematic);
if (sch == NULL) {
return 1;
@ -482,7 +482,7 @@ int doNgspiceNetlist(QString schematic, QString netlist)
int doXyceNetlist(QString schematic, QString netlist)
{
QucsSettings.DefaultSimulator = spicecompat::simXyceSer;
QucsSettings.DefaultSimulator = spicecompat::simXyce;
Schematic *sch = openSchematic(schematic);
if (sch == NULL) {
return 1;

View File

@ -503,8 +503,7 @@ void Module::registerModules (void) {
REGISTER_SIMULATION_1 (AC_Sim);
REGISTER_SIMULATION_1 (SP_Sim);
if (QucsSettings.DefaultSimulator == spicecompat::simQucsator||
QucsSettings.DefaultSimulator == spicecompat::simXyceSer||
QucsSettings.DefaultSimulator == spicecompat::simXycePar) {
QucsSettings.DefaultSimulator == spicecompat::simXyce) {
REGISTER_SIMULATION_1 (HB_Sim);
}
REGISTER_SIMULATION_1 (Param_Sweep);
@ -525,8 +524,7 @@ void Module::registerModules (void) {
REGISTER_SIMULATION_1 (SpiceSENS_AC);
}
if ((QucsSettings.DefaultSimulator == spicecompat::simXycePar)||
(QucsSettings.DefaultSimulator == spicecompat::simXyceSer)) {
if (QucsSettings.DefaultSimulator == spicecompat::simXyce) {
REGISTER_SIMULATION_1 (XyceScript);
REGISTER_SIMULATION_1 (SpiceSENS_Xyce);
REGISTER_SIMULATION_1 (SpiceSENS_TR_Xyce);

View File

@ -3060,7 +3060,7 @@ void QucsApp::slotSimSettings()
SimSettingsDialog *SetDlg = new SimSettingsDialog(this);
SetDlg->exec();
delete SetDlg;
SimulatorLabel->setText(spicecompat::getDefaultSimulatorName());
SimulatorLabel->setText(spicecompat::getDefaultSimulatorName(QucsSettings.DefaultSimulator));
}
void QucsApp::slotSimulateWithSpice()

View File

@ -755,8 +755,7 @@ void QucsApp::slotShowLastNetlist()
QWidget *w = DocumentTab->currentWidget();
if (QucsSettings.DefaultSimulator == spicecompat::simXycePar ||
QucsSettings.DefaultSimulator == spicecompat::simXyceSer) {
if (QucsSettings.DefaultSimulator == spicecompat::simXyce) {
if (isTextDocument(w)) {
QMessageBox::information(this, tr("Show netlist"),
tr("Not a schematic tab!"));
@ -778,8 +777,7 @@ void QucsApp::slotShowLastNetlist()
netlists.append(QDir::toNativeSeparators(QucsSettings.S4Qworkdir
+ "/spice4qucs.cir"));
break;
case spicecompat::simXycePar: // Xyce generates one netlist for
case spicecompat::simXyceSer: // every simulation
case spicecompat::simXyce: // Xyce generates one netlist for every simulation
for(const auto &sim : sim_lst) {
netlists.append(QDir::toNativeSeparators(QucsSettings.S4Qworkdir
+ "/spice4qucs."

View File

@ -926,7 +926,7 @@ void QucsApp::initToolBar()
void QucsApp::initStatusBar()
{
// To reserve enough space, insert the longest text and rewrite it afterwards.
SimulatorLabel = new QLabel(spicecompat::getDefaultSimulatorName());
SimulatorLabel = new QLabel(spicecompat::getDefaultSimulatorName(QucsSettings.DefaultSimulator));
statusBar()->addPermanentWidget(SimulatorLabel, 0);
WarningLabel = new QLabel(tr("no warnings"), statusBar());

View File

@ -503,8 +503,7 @@ inline QStringList getBlacklistedLibraries(QString dir)
switch (QucsSettings.DefaultSimulator) {
case spicecompat::simQucsator : filename = dir + QDir::separator()+ "qucs.blacklist";
break;
case spicecompat::simXycePar:
case spicecompat::simXyceSer: filename = dir + QDir::separator()+ "xyce.blacklist";
case spicecompat::simXyce: filename = dir + QDir::separator()+ "xyce.blacklist"; //TODO ZERGUD
break;
case spicecompat::simNgspice:
case spicecompat::simSpiceOpus: filename = dir + QDir::separator() + "ngspice.blacklist";

View File

@ -1405,8 +1405,7 @@ bool Schematic::throughAllComps(QTextStream *stream, int& countInit,
unsigned whatisit = isAnalog?1:(isVerilog?4:2);
if(isAnalog) {
if (QucsSettings.DefaultSimulator!=spicecompat::simQucsator) {
if ((QucsSettings.DefaultSimulator==spicecompat::simXyceSer)||
(QucsSettings.DefaultSimulator==spicecompat::simXycePar))
if (QucsSettings.DefaultSimulator==spicecompat::simXyce)
whatisit = 16;
else whatisit = 8;
} else whatisit = 1;

View File

@ -75,8 +75,7 @@ QString SpiceFunc::getExpression(bool)
QString s;
s.clear();
for (Property *pp : Props) {
if ((QucsSettings.DefaultSimulator==spicecompat::simXyceSer)||
(QucsSettings.DefaultSimulator==spicecompat::simXycePar))
if (QucsSettings.DefaultSimulator==spicecompat::simXyce)
s += QString(".FUNC %1 %2\n").arg(pp->Name).arg(pp->Value);
else s += QString(".FUNC %1 = %2\n").arg(pp->Name).arg(pp->Value);
}