Added the KLU support to ADMS models

This commit is contained in:
Francesco Lannutti 2020-06-16 13:36:44 +02:00 committed by Holger Vogt
parent 77fa5c06a9
commit 72d78a2053
5 changed files with 258 additions and 0 deletions

View File

@ -0,0 +1,175 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Written by Laurent Lemaitre - r29173@users.sourceforge.net
Documentation:
http://sourceforge.net/docman/display_doc.php?docid=18993&group_id=84289
Target Interface: ngspice
Supported by adms-1.x.x
This file is used by adms - http://sourceforge.net/projects/mot-adms.
adms is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
adms is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with adms; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<!DOCTYPE admst SYSTEM "admst.dtd">
<admst version="2.3.0" xmlns:admst="http://mot-adms.sourceforge.net/xml-files/admst">
<admst:template match="dectype">
<admst:choose>
<admst:when test="[type='real']">
<admst:text format=" double "/>
</admst:when>
<admst:when test="[type='integer']">
<admst:text format=" int "/>
</admst:when>
<admst:otherwise>
<admst:text format=" char* "/>
</admst:otherwise>
</admst:choose>
</admst:template>
<admst:template match="code">
<admst:value-of select="attribute[name='ngspicename']/value"/>
<admst:variable name="module" select="%s"/>
/**********
Author: 2020 Francesco Lannutti
**********/
#include &quot;ngspice/ngspice.h&quot;
#include &quot;ngspice/cktdefs.h&quot;
#include &quot;$(module)defs.h&quot;
#include &quot;ngspice/sperror.h&quot;
#include &quot;ngspice/klu-binding.h&quot;
#include &lt;stdlib.h&gt;
static
int
BindCompare (const void *a, const void *b)
{
BindElement *A, *B ;
A = (BindElement *)a ;
B = (BindElement *)b ;
return ((int)(A->Sparse - B->Sparse)) ;
}
int
$(module)bindCSC (GENmodel *inModel, CKTcircuit *ckt)
{
$(module)model *model = ($(module)model *)inModel ;
$(module)instance *here ;
double *i ;
BindElement *matched, *BindStruct ;
size_t nz ;
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
/* loop through all the $(module) models */
for ( ; model != NULL ; model = $(module)nextModel(model))
{
/* loop through all the instances of the model */
for (here = $(module)instances(model); here != NULL ; here = $(module)nextInstance(here))
{
<admst:for-each select="jacobian">
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
CREATE_KLU_BINDING_TABLE(PTR_J_%s_%s, $(module)%s%sBinding, %sNode, %sNode);
</admst:for-each>
}
}
return (OK) ;
}
int
$(module)bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
{
$(module)model *model = ($(module)model *)inModel ;
$(module)instance *here ;
NG_IGNORE (ckt) ;
/* loop through all the $(module) models */
for ( ; model != NULL ; model = $(module)nextModel(model))
{
/* loop through all the instances of the model */
for (here = $(module)instances(model); here != NULL ; here = $(module)nextInstance(here))
{
<admst:for-each select="jacobian">
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(PTR_J_%s_%s, $(module)%s%sBinding, %sNode, %sNode);
</admst:for-each>
}
}
return (OK) ;
}
int
$(module)bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
{
$(module)model *model = ($(module)model *)inModel ;
$(module)instance *here ;
NG_IGNORE (ckt) ;
/* loop through all the $(module) models */
for ( ; model != NULL ; model = $(module)nextModel(model))
{
/* loop through all the instances of the model */
for (here = $(module)instances(model); here != NULL ; here = $(module)nextInstance(here))
{
<admst:for-each select="jacobian">
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
CONVERT_KLU_BINDING_TABLE_TO_REAL(PTR_J_%s_%s, $(module)%s%sBinding, %sNode, %sNode);
</admst:for-each>
}
}
return (OK) ;
}
</admst:template>
<admst:for-each select="/module">
<admst:value-of select="attribute[name='ngspicename']/value"/>
<admst:open file="%sbindCSC.c">
<admst:value-of select="/simulator/package_string"/>
<admst:text format="/***\n*** Interface: %s\n"/>
<admst:value-of select="/simulator/currentdate"/>
<admst:value-of select="/simulator/fullname"/>
<admst:text format=" *** created by: %s - %s ***/\n"/>
<admst:apply-templates select="." match="code"/>
</admst:open>
<admst:value-of select="attribute[name='ngspicename']/value"/>
<admst:message format="%sbindCSC.c: file created\n"/>
</admst:for-each>
</admst>

View File

@ -280,6 +280,16 @@ typedef struct s$(module)instance {
</admst:if>
</admst:for-each>
#define $(module)numStates 0
#ifdef KLU
<admst:for-each select="jacobian">
<admst:value-of select="column/name"/>
<admst:value-of select="row/name"/>
BindElement *$(module)%s%sBinding ;
</admst:for-each>
#endif
} $(module)instance ;
enum {

View File

@ -53,6 +53,12 @@ extern int $(module)trunc(GENmodel*,CKTcircuit*,double*);
extern int $(module)unsetup(GENmodel*,CKTcircuit*);
extern void $(module)destroy(void);
#ifdef KLU
extern int $(module)bindCSC (GENmodel*, CKTcircuit*) ;
extern int $(module)bindCSCComplex (GENmodel*, CKTcircuit*) ;
extern int $(module)bindCSCComplexToReal (GENmodel*, CKTcircuit*) ;
#endif
#endif
</admst:template>

View File

@ -93,6 +93,12 @@ SPICEdev $(module)info = {
.DEVdump = NULL,
.DEVacct = NULL,
#endif
#ifdef KLU
.DEVbindCSC = $(module)bindCSC,
.DEVbindCSCComplex = $(module)bindCSCComplex,
.DEVbindCSCComplexToReal = $(module)bindCSCComplexToReal,
#endif
};

View File

@ -57,6 +57,10 @@ BUILT_SOURCES = \\
$(module)temp.c \\
$(module)trunc.c
if KLU_WANTED
BUILT_SOURCES += $(module)bindCSC.c
endif
lib$(module)_la_SOURCES = \\
\$(BUILT_SOURCES)
@ -84,6 +88,62 @@ MAINTAINERCLEANFILES = Makefile.in \\
DISTCLEANFILES = Makefile.am \\
Makefile.in
if KLU_WANTED
\%.c \%.hxx \\
\%acld.c \%ask.c \%bindCSC.c \%defs.h \%del.c \%dest.c \%ext.h \%guesstopology.c \\
\%init.c \%init.h \%itf.h \%load.c \%mask.c \%mdel.c \%mpar.c \%par.c \\
\%pzld.c \%setup.c \%temp.c \%trunc.c \\
: \$(srcdir)/admsva/\%.va \\
\$(ADMSXMLINTERFACE)/ngspiceVersion.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEbindCSC.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEitf.h.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEinit.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEinit.h.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEext.h.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEdefs.h.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEask.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEmask.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEpar.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEmpar.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEload.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEacld.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEpzld.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEtemp.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEtrunc.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEsetup.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEdel.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEmdel.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEdest.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEnoise.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULEguesstopology.c.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULE.hxx.xml \\
\$(ADMSXMLINTERFACE)/ngspiceMODULE.c.xml
\$(ADMSXML) -I\$(srcdir) -I\$(srcdir)/admsva \$&lt; \\
-e \$(ADMSXMLINTERFACE)/ngspiceVersion.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEbindCSC.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEitf.h.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEinit.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEinit.h.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEext.h.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEdefs.h.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEask.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEmask.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEpar.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEmpar.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEload.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEacld.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEpzld.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEtemp.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEtrunc.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEsetup.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEdel.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEmdel.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEdest.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEnoise.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEguesstopology.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULE.hxx.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULE.c.xml
else
\%.c \%.hxx \\
\%acld.c \%.analogfunction.c \%ask.c \%defs.h \%del.c \%dest.c \%ext.h \%guesstopology.c \\
\%init.c \%init.h \%itf.h \%load.c \%mask.c \%mdel.c \%mpar.c \%par.c \\
@ -141,6 +201,7 @@ DISTCLEANFILES = Makefile.am \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULEguesstopology.c.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULE.hxx.xml \\
-e \$(ADMSXMLINTERFACE)/ngspiceMODULE.c.xml
endif
</admst:template>