mirror of
https://github.com/ra3xdh/qucs_s
synced 2025-03-28 21:13:26 +00:00
Add file I/V sources #254
This commit is contained in:
parent
1d37868497
commit
0f39840d0d
@ -19,6 +19,8 @@
|
||||
#include "schematic.h"
|
||||
#include "misc.h"
|
||||
|
||||
#include "extsimkernels/spicecompat.h"
|
||||
|
||||
iFile::iFile()
|
||||
{
|
||||
Description = QObject::tr("file based current source");
|
||||
@ -48,11 +50,12 @@ iFile::iFile()
|
||||
ty = y2+4;
|
||||
Model = "Ifile";
|
||||
Name = "I";
|
||||
SpiceModel = "A";
|
||||
|
||||
Props.append(new Property("File", "ifile.dat", true,
|
||||
QObject::tr("name of the sample file")));
|
||||
Props.append(new Property("Interpolator", "linear", false,
|
||||
QObject::tr("interpolation type")+" [hold, linear, cubic]"));
|
||||
QObject::tr("interpolation type")+" [hold, linear]"));
|
||||
Props.append(new Property("Repeat", "no", false,
|
||||
QObject::tr("repeat waveform")+" [no, yes]"));
|
||||
Props.append(new Property("G", "1", false, QObject::tr("current gain")));
|
||||
@ -106,3 +109,23 @@ QString iFile::netlist()
|
||||
|
||||
return s + "\n";
|
||||
}
|
||||
|
||||
QString iFile::spice_netlist(bool isXyce)
|
||||
{
|
||||
Q_UNUSED(isXyce);
|
||||
QString s = SpiceModel + Name;
|
||||
QString modname = "mod_" + Model + Name;
|
||||
QString p1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name);
|
||||
QString p2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name);
|
||||
s += QString(" %id([%1 %2]) %3\n").arg(p2).arg(p1).arg(modname);
|
||||
QString file = getSubcircuitFile();
|
||||
QString sc = getProperty("G")->Value;
|
||||
QString step = "false";
|
||||
QString delay = getProperty("T")->Value;
|
||||
if (getProperty("Interpolator")->Value != "linear") step = "true";
|
||||
s += QString(".MODEL %1 filesource (file=\"%2\" amplscale=[%3] amplstep=%4 "
|
||||
"amploffset=[0] timeoffset=%5 timescale=1)\n")
|
||||
.arg(modname).arg(file).arg(sc).arg(step).arg(delay);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
|
||||
protected:
|
||||
QString netlist();
|
||||
QString spice_netlist(bool isXyce);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "schematic.h"
|
||||
#include "misc.h"
|
||||
|
||||
#include "extsimkernels/spicecompat.h"
|
||||
|
||||
vFile::vFile()
|
||||
{
|
||||
Description = QObject::tr("file based voltage source");
|
||||
@ -50,11 +52,12 @@ vFile::vFile()
|
||||
ty = y2+4;
|
||||
Model = "Vfile";
|
||||
Name = "V";
|
||||
SpiceModel = "A";
|
||||
|
||||
Props.append(new Property("File", "vfile.dat", true,
|
||||
QObject::tr("name of the sample file")));
|
||||
Props.append(new Property("Interpolator", "linear", false,
|
||||
QObject::tr("interpolation type")+" [hold, linear, cubic]"));
|
||||
QObject::tr("interpolation type")+" [hold, linear]"));
|
||||
Props.append(new Property("Repeat", "no", false,
|
||||
QObject::tr("repeat waveform")+" [no, yes]"));
|
||||
Props.append(new Property("G", "1", false, QObject::tr("voltage gain")));
|
||||
@ -108,3 +111,23 @@ QString vFile::netlist()
|
||||
|
||||
return s + "\n";
|
||||
}
|
||||
|
||||
QString vFile::spice_netlist(bool isXyce)
|
||||
{
|
||||
Q_UNUSED(isXyce);
|
||||
QString s = SpiceModel + Name;
|
||||
QString modname = "mod_" + Model + Name;
|
||||
QString p1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name);
|
||||
QString p2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name);
|
||||
s += QString(" %vd([%1 %2]) %3\n").arg(p1).arg(p2).arg(modname);
|
||||
QString file = getSubcircuitFile();
|
||||
QString sc = getProperty("G")->Value;
|
||||
QString step = "false";
|
||||
QString delay = getProperty("T")->Value;
|
||||
if (getProperty("Interpolator")->Value != "linear") step = "true";
|
||||
s += QString(".MODEL %1 filesource (file=\"%2\" amplscale=[%3] amplstep=%4 "
|
||||
"amploffset=[0] timeoffset=%5 timescale=1)\n")
|
||||
.arg(modname).arg(file).arg(sc).arg(step).arg(delay);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
|
||||
protected:
|
||||
QString netlist();
|
||||
QString spice_netlist(bool isXyce);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -322,11 +322,10 @@ void Module::registerModules (void) {
|
||||
|
||||
REGISTER_SOURCE_1 (iExp);
|
||||
REGISTER_SOURCE_1 (vExp);
|
||||
REGISTER_SOURCE_1 (vFile);
|
||||
REGISTER_SOURCE_1 (iFile);
|
||||
|
||||
if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
||||
REGISTER_SOURCE_1 (vFile);
|
||||
REGISTER_SOURCE_1 (iFile);
|
||||
} else {
|
||||
if (QucsSettings.DefaultSimulator != spicecompat::simQucsator) {
|
||||
REGISTER_SOURCE_1 (S4Q_V);
|
||||
REGISTER_SOURCE_1 (S4Q_I);
|
||||
REGISTER_SOURCE_1 (Src_eqndef);
|
||||
|
Loading…
x
Reference in New Issue
Block a user