Skip to content

Commit

Permalink
Merge pull request #838 from ra3xdh/enable_var_as_device_parameter
Browse files Browse the repository at this point in the history
Enable variables for blue nonlinear devices
  • Loading branch information
ra3xdh committed Jul 13, 2024
2 parents 45eda17 + 252b9c7 commit 949761c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 53 deletions.
4 changes: 1 addition & 3 deletions qucs/components/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,7 @@ QString Component::form_spice_param_list(QStringList &ignore_list, QStringList &
} else {
nam = Props.at(i)->Name;
}
double val, fac;
misc::str2num(Props.at(i)->Value, val, unit, fac);
val *= fac;
QString val = spicecompat::normalize_value(Props.at(i)->Value);
par_str += QString("%1=%2 ").arg(nam).arg(val);
}

Expand Down
2 changes: 1 addition & 1 deletion qucs/components/equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Component* Equation::newOne()

Element* Equation::info(QString& Name, char* &BitmapFile, bool getNewOne)
{
Name = QObject::tr("Qucs legacy equation");
Name = QObject::tr("Qucsator equation");
BitmapFile = (char *) "equation";

if(getNewOne) return new Equation();
Expand Down
53 changes: 5 additions & 48 deletions qucs/components/param_sweep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ Param_Sweep::Param_Sweep()
QObject::tr("stop value for sweep")));
Props.append(new Property("Points", "20", true,
QObject::tr("number of simulation steps")));
Props.append(new Property("SweepModel","false",false,
"[true,false]"));
}

Param_Sweep::~Param_Sweep()
Expand Down Expand Up @@ -147,26 +145,8 @@ QString Param_Sweep::getNgspiceBeforeSim(QString sim, int lvl)
for(constListIterator=parameter_list.begin(); constListIterator!=parameter_list.end();++constListIterator)
{
QString par = *constListIterator;

bool modelsweep = false; // Find component and its modelstring
bool compfound = false;
bool temper_sweep = false;
QString mod,mod_par;

if (!par.contains('@')) {
QStringList par_lst = par.split('.',qucs::SkipEmptyParts);
if (par_lst.count()>1) {
mod_par = par_lst.at(1);
// Schematic *sch = (Schematic *) QucsMain->DocumentTab->currentPage();
Schematic *sch = getSchematic();
Component *pc = sch->getComponentByName(par_lst.at(0));
if (pc != NULL) {
mod = pc->getSpiceNetlist().section('\n',1,1,QString::SectionSkipEmpty)
.section(' ',1,1,QString::SectionSkipEmpty);
if (!mod.isEmpty()) modelsweep = true;
}
}
}

Schematic *sch = getSchematic();
Component *pc = sch->getComponentByName(getProperty("Param")->Value);
Expand All @@ -175,19 +155,12 @@ QString Param_Sweep::getNgspiceBeforeSim(QString sim, int lvl)

if (step_var == "temp" || step_var == "temper") temper_sweep = true;

if (modelsweep) { // Model parameter sweep
s += QString("altermod %1 %2 = $%3_act%4").arg(mod).arg(mod_par).arg(step_var).arg(nline_char);
if (temper_sweep) {
s += QString("option temp = $%1_act%2").arg(step_var).arg(nline_char);
} else if (compfound) {
s += QString("alter %1 = $%2_act%3").arg(par).arg(step_var).arg(nline_char);
} else {
QString mswp = getProperty("SweepModel")->Value;
if (mswp == "true") {
s += QString("altermod %1 = $%2_act%3").arg(par).arg(step_var).arg(nline_char);
} else if (temper_sweep) {
s += QString("option temp = $%1_act%2").arg(step_var).arg(nline_char);
} else if (compfound) {
s += QString("alter %1 = $%2_act%3").arg(par).arg(step_var).arg(nline_char);
} else {
s += QString("alterparam %1 = $%2_act%3reset%3").arg(par).arg(step_var).arg(nline_char);
}
s += QString("alterparam %1 = $%2_act%3reset%3").arg(par).arg(step_var).arg(nline_char);
}
}
return s;
Expand Down Expand Up @@ -261,19 +234,3 @@ QString Param_Sweep::spice_netlist(bool isXyce)
return s.toLower();
}

// -------------------------------------------------------
QString Param_Sweep::netlist()
{
QString s = Model+":"+Name;

// output all node names
for (Port *p1 : Ports)
s += " "+p1->Connection->Name; // node names

// output all properties
for(unsigned int i=0; i <= Props.count()-2; i++)
if(Props.at(i)->Name != "Symbol")
s += " "+Props.at(i)->Name+"=\""+Props.at(i)->Value+"\"";

return s + '\n';
}
1 change: 0 additions & 1 deletion qucs/components/param_sweep.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Param_Sweep : public qucs::component::SimulationComponent {

protected:
QString spice_netlist(bool isXyce);
QString netlist();
QString param_split_str=";";
};

Expand Down
1 change: 1 addition & 0 deletions qucs/diagrams/diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ void Diagram::createAxisLabels() {

QStringList used_kernels, used_simulations;
for (const auto pg: Graphs) {
if (!pg->Var.contains("/")) continue; // Qucsator data
QString kernel_name = pg->Var.section('/', 0, 0);
QString var_name = pg->Var;
auto p = var_name.indexOf('/');
Expand Down

0 comments on commit 949761c

Please sign in to comment.