diff --git a/src/spicelib/devices/hicum2/hicum2mpar.c b/src/spicelib/devices/hicum2/hicum2mpar.c index 5b348d60e..fb2b07dec 100644 --- a/src/spicelib/devices/hicum2/hicum2mpar.c +++ b/src/spicelib/devices/hicum2/hicum2mpar.c @@ -40,20 +40,6 @@ HICUMmParam(int param, IFvalue *value, GENmodel *inModel) }; setModelcardPara(HICUMinfo.DEVpublic.modelParms[para_found].keyword, value->rValue); - //printf("%s",HICUMinfo.DEVpublic.modelParms[para_found].keyword); - -// static IFparm * -// find_model_parameter(const char *name, IFdevice *device) -// { -// IFparm *p = device->modelParms; -// IFparm *p_end = p + *(device->numModelParms); - -// for (; p < p_end; p++) -// if (strcmp(name, p->keyword) == 0) -// return p; - -// return NULL; -// } switch(param) { diff --git a/src/spicelib/devices/hicum2/model_class.cpp b/src/spicelib/devices/hicum2/model_class.cpp index 122cfbc93..d11fe7caa 100644 --- a/src/spicelib/devices/hicum2/model_class.cpp +++ b/src/spicelib/devices/hicum2/model_class.cpp @@ -5,19 +5,98 @@ #include #include #include +extern "C" { +#include "ngspice/cktdefs.h" +#include "ngspice/ngspice.h" +#include "ngspice/smpdefs.h" +#include "ngspice/const.h" +#include "ngspice/sperror.h" +#include "ngspice/ifsim.h" +#include "ngspice/suffix.h" +} Parameter::Parameter(double value_default, double min_value, double max_value) { + /* Modelcard parameter constructor. + Input + ----- + value_default : double + Default value of the parameter. + min_value : double + Minimum value of the parameter. + max_value : double + Maximum value of the parameter. + */ value_default = value_default; value_min = min_value; value_max = max_value; }; + void Parameter::setValue(double new_value){ + /* Set the value of the parameter. TODO: check limits value_min/max + Input + ----- + new_value : double + The new value to be set. + */ value = new_value; }; + double Parameter::getValue(){ + /* Return the value of the parameter. + Output + ----- + value : double + The value of the parameter. + */ return value; }; + +Node::Node(CKTcircuit * ckt, NGSpiceModel * model , char * name){ + /* Node constructor. + Output + ----- + ckt : CKTcircuit * + The circuit in which the node shall be allocated. + model : NGSpiceModel * + The model that contains the node. + name : char * + The name of the node. + */ + int error = 0; + + CKTnode *tmp; + ckt = ckt; + name = name; + + //allocate the node + error = CKTmkVolt(ckt,&tmp, (char*)model->name, name); + //if(error) return(error); //why should there be an error? + id = tmp->number; + // what is the purpose of this? + // if (ckt->CKTcopyNodesets) { + // if (CKTinst2Node(ckt,here,2,&tmpNode,&tmpName)==OK) { + // if (tmpNode->nsGiven) { + // tmp->nodeset=tmpNode->nodeset; + // tmp->nsGiven=tmpNode->nsGiven; + // } + // } + // } +}; + +double Node::getPotential(){ + /* Return the potential of the node from the RHSold. + */ + return *(ckt->CKTrhsOld+id); +}; + + +Branch::Branch(Node * node_from,Node * node_to,std::vector depends){ + node_from = node_from; + node_to = node_to; + branch_dependencies = depends; +}; + double inf = std::numeric_limits::infinity(); HICUML2::HICUML2(){ diff --git a/src/spicelib/devices/hicum2/model_class.hpp b/src/spicelib/devices/hicum2/model_class.hpp index 851851fbd..5782a5e3e 100644 --- a/src/spicelib/devices/hicum2/model_class.hpp +++ b/src/spicelib/devices/hicum2/model_class.hpp @@ -5,7 +5,13 @@ //for the time beeing, HICUM is the first model to use this. #ifdef __cplusplus #include +#include #include +extern "C" { +#include "ngspice/cktdefs.h" +} + +class NGSpiceModel; class Parameter { @@ -17,18 +23,44 @@ class Parameter Parameter(double value_default, double min_value, double max_value); void setValue(double new_value); - double getValue(); + double getValue(); // -> maybe with operator overloading +}; + +class Node +{ + public: + int id; + char * name; + CKTcircuit * ckt; //pointer to the circuit in which the node resides + double getPotential(); + Node(CKTcircuit * ckt, NGSpiceModel * model, char * name); +}; + +class Branch +{ + //A branch specifies a current that flows from node_from to node_to + public: + double value; //the current of the branch + std::unordered_map derivatives; //a map whose keys are node ids and the value is the derivative with that node + std::vector branch_dependencies; //all nodes for which a derivative is defined + Node * node_from; //the node where the current originates + Node * node_to; //the node where the current is flowing to + Branch(Node * node_from, Node * node_to, std::vector depends); }; class NGSpiceModel { public: std::unordered_map modelcard; //the modelcard of the model + std::vector nodes; //the nodes of the model + std::vector branches; //the branches of the model + const char * name = "None"; //the branches of the model }; class HICUML2 : public NGSpiceModel { public: + const char * name = "hl2"; HICUML2(); }; #endif