Browse Source

command mdump

h_vogt 14 years ago
parent
commit
dffe4ed156
  1. 5
      ChangeLog
  2. 31
      src/frontend/com_cdump.c
  3. 1
      src/frontend/com_cdump.h
  4. 4
      src/frontend/commands.c
  5. 46
      src/frontend/spiceif.c
  6. 2
      src/include/ngspice/smpdefs.h
  7. 5
      src/maths/sparse/spoutput.c
  8. 11
      src/maths/sparse/spsmp.c
  9. 2
      src/spicelib/analysis/cktpzstr.c
  10. 4
      src/spicelib/devices/txl/txlload.c

5
ChangeLog

@ -1,3 +1,8 @@
2012-02-19 Holger Vogt
* spiceif.c: savesnap, loadsnap enabled (still experimental!)
* com_cdump.c, com_cdump.h, commands.c, smpdefs.h, spoutput.c, spsmp.c,
cktpzstr.c, txlload.c: command mdump to dump the matrix to stdout or to a file
2012-02-11 Dietmar Warning 2012-02-11 Dietmar Warning
* src/spicelib/devices/asrc/*.c,*.h,Makefile.am * src/spicelib/devices/asrc/*.c,*.h,Makefile.am
* src/frontend/inpcom.c, * src/frontend/inpcom.c,

31
src/frontend/com_cdump.c

@ -1,4 +1,5 @@
/* Command cdump: dump the control structure to the console output */ /* Command cdump: dump the control structure to the console output */
/* Command mdump: dump the matrix of the actual circuit to stdout or a file */
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
#include <stdio.h> #include <stdio.h>
@ -7,7 +8,9 @@
#include "control.h" #include "control.h"
#include "ngspice/cpextern.h" #include "ngspice/cpextern.h"
#include "ngspice/fteext.h"
#include "ngspice/smpdefs.h"
#include "ngspice/cktdefs.h"
#include "com_cdump.h" #include "com_cdump.h"
static int indent; static int indent;
@ -143,3 +146,29 @@ com_cdump(wordlist *wl)
dodump(c); dodump(c);
return; return;
} }
void
com_mdump(wordlist *wl)
{
CKTcircuit *ckt = NULL;
char *s;
if (!ft_curckt || !ft_curckt->ci_ckt) {
fprintf(cp_err, "Error: no circuit loaded.\n");
return;
}
ckt = ft_curckt->ci_ckt;
if (ckt->CKTmatrix)
if (wl == NULL)
SMPprint( ckt->CKTmatrix , NULL);
else {
s = cp_unquote(wl->wl_word);
SMPprint( ckt->CKTmatrix , s);
}
else
fprintf(cp_err, "Error: no matrix available.\n");
return;
}

1
src/frontend/com_cdump.h

@ -2,6 +2,7 @@
#define _COM_CDUMP_H #define _COM_CDUMP_H
void com_cdump(wordlist *wl); void com_cdump(wordlist *wl);
void com_mdump(wordlist *wl);
#define TABINDENT 2 /* CDHW */ /* The orginal value was 8 */ #define TABINDENT 2 /* CDHW */ /* The orginal value was 8 */
#endif #endif

4
src/frontend/commands.c

@ -549,6 +549,10 @@ struct comm spcp_coms[] = {
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 0, { 0, 0, 0, 0 }, E_DEFHMASK, 0, 0,
NULL, NULL,
": Dump the current control structures." } , ": Dump the current control structures." } ,
{ "mdump", com_mdump, FALSE, FALSE,
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 1,
NULL,
"outfile: Dump the current matrix." } ,
{ "settype", com_stype, FALSE, FALSE, { "settype", com_stype, FALSE, FALSE,
{ 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS, { 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS,
NULL, NULL,

46
src/frontend/spiceif.c

@ -70,6 +70,7 @@ CDHW*/
#include "ngspice/evtproto.h" #include "ngspice/evtproto.h"
#include "ngspice/evtudn.h" #include "ngspice/evtudn.h"
/* gtri - end - wbk - 5/20/91 - Add stuff for user-defined nodes */ /* gtri - end - wbk - 5/20/91 - Add stuff for user-defined nodes */
#include "ngspice/mif.h"
#endif #endif
/* static declarations */ /* static declarations */
@ -1312,6 +1313,14 @@ if_getstat(CKTcircuit *ckt, char *name) {
} }
} }
/* Some small updates to make it work, h_vogt, Feb. 2012
Still very experimental !
It is now possible to save a state during transient simulation,
reload it later into a new ngspice run and resume simulation.
XSPICE code models probably will not do.
LTRA transmission line will not do.
Many others are not tested.
*/
#ifdef EXPERIMENTAL_CODE #ifdef EXPERIMENTAL_CODE
#include "ngspice/cktdefs.h" #include "ngspice/cktdefs.h"
@ -1499,12 +1508,12 @@ do {\
_foo(ckt->CKTirhs, double,size); _foo(ckt->CKTirhs, double,size);
_foo(ckt->CKTirhsOld, double,size); _foo(ckt->CKTirhsOld, double,size);
_foo(ckt->CKTirhsSpare, double,size); _foo(ckt->CKTirhsSpare, double,size);
_foo(ckt->CKTrhsOp, double,size);
_foo(ckt->CKTsenRhs, double,size);
_foo(ckt->CKTseniRhs, double,size);
// _foo(ckt->CKTrhsOp, double,size);
// _foo(ckt->CKTsenRhs, double,size);
// _foo(ckt->CKTseniRhs, double,size);
_foo(ckt->CKTtimePoints,double,-1);
_foo(ckt->CKTdeltaList,double,-1);
// _foo(ckt->CKTtimePoints,double,-1);
// _foo(ckt->CKTdeltaList,double,-1);
_foo(ckt->CKTbreaks,double,ckt->CKTbreakSize); _foo(ckt->CKTbreaks,double,ckt->CKTbreakSize);
@ -1520,8 +1529,9 @@ do {\
_foo(ft_curckt->ci_curTask->TSKname, char, -1); _foo(ft_curckt->ci_curTask->TSKname, char, -1);
{ /* avoid invalid lvalue assignment errors in the macro _foo() */ { /* avoid invalid lvalue assignment errors in the macro _foo() */
TRANan * lname = (TRANan *)ft_curckt->ci_curTask->jobs;
_foo(lname,TRANan,1);
// TRANan * lname = (TRANan *)ft_curckt->ci_curTask->jobs;
// _foo(lname,TRANan,1);
_foo(ft_curckt->ci_curTask->jobs,JOB,-1);
} }
ft_curckt->ci_curTask->jobs->JOBname = NULL; ft_curckt->ci_curTask->jobs->JOBname = NULL;
// ckt->CKTcurJob = (&(ft_curckt->ci_curTask->taskOptions)) -> jobs; // ckt->CKTcurJob = (&(ft_curckt->ci_curTask->taskOptions)) -> jobs;
@ -1536,6 +1546,14 @@ do {\
_foo(ckt->CKTstat,STATistics,1); _foo(ckt->CKTstat,STATistics,1);
#ifdef XSPICE
_foo(ckt->evt,Evt_Ckt_Data_t,1);
_foo(ckt->enh,Enh_Ckt_Data_t,1);
g_mif_info.breakpoint.current = ckt->enh->breakpoint.current;
g_mif_info.breakpoint.last = ckt->enh->breakpoint.last;
#endif
tfree(my_ckt); tfree(my_ckt);
fclose(file); fclose(file);
@ -1656,12 +1674,12 @@ void com_savesnap(wordlist *wl)
_foo(ckt->CKTirhs,double,size); _foo(ckt->CKTirhs,double,size);
_foo(ckt->CKTirhsOld,double,size); _foo(ckt->CKTirhsOld,double,size);
_foo(ckt->CKTirhsSpare,double,size); _foo(ckt->CKTirhsSpare,double,size);
_foo(ckt->CKTrhsOp,double,size);
_foo(ckt->CKTsenRhs,double,size);
_foo(ckt->CKTseniRhs,double,size);
// _foo(ckt->CKTrhsOp,double,size);
// _foo(ckt->CKTsenRhs,double,size);
// _foo(ckt->CKTseniRhs,double,size);
_foo(ckt->CKTtimePoints,double,ckt->CKTtimeListSize);
_foo(ckt->CKTdeltaList,double,ckt->CKTtimeListSize);
// _foo(ckt->CKTtimePoints,double,ckt->CKTtimeListSize);
// _foo(ckt->CKTdeltaList,double,ckt->CKTtimeListSize);
/* need to save the breakpoints, or something */ /* need to save the breakpoints, or something */
@ -1686,6 +1704,10 @@ void com_savesnap(wordlist *wl)
_foo(ckt->CKTstat,STATistics,1); _foo(ckt->CKTstat,STATistics,1);
#ifdef XSPICE
_foo(ckt->evt,Evt_Ckt_Data_t,1);
_foo(ckt->enh,Enh_Ckt_Data_t,1);
#endif
fclose(file); fclose(file);

2
src/include/ngspice/smpdefs.h

@ -30,7 +30,7 @@ int SMPmatSize( SMPmatrix *);
int SMPnewMatrix( SMPmatrix ** ); int SMPnewMatrix( SMPmatrix ** );
void SMPdestroy( SMPmatrix *); void SMPdestroy( SMPmatrix *);
int SMPpreOrder( SMPmatrix *); int SMPpreOrder( SMPmatrix *);
void SMPprint( SMPmatrix * , FILE *);
void SMPprint( SMPmatrix * , char *);
void SMPgetError( SMPmatrix *, int *, int *); void SMPgetError( SMPmatrix *, int *, int *);
int SMPcProdDiag( SMPmatrix *, SPcomplex *, int *); int SMPcProdDiag( SMPmatrix *, SPcomplex *, int *);
int SMPcDProd(SMPmatrix *Matrix, SPcomplex *pMantissa, int *pExponent); int SMPcDProd(SMPmatrix *Matrix, SPcomplex *pMantissa, int *pExponent);

5
src/maths/sparse/spoutput.c

@ -55,7 +55,10 @@
int Printer_Width = PRINTER_WIDTH; int Printer_Width = PRINTER_WIDTH;
#include "ngspice/config.h"
#ifdef HAS_WINDOWS
#include "ngspice/wstdio.h"
#endif

11
src/maths/sparse/spsmp.c

@ -280,13 +280,14 @@ SMPpreOrder(SMPmatrix *Matrix)
/* /*
* SMPprint() * SMPprint()
*/ */
/*ARGSUSED*/
void void
SMPprint(SMPmatrix *Matrix, FILE *File)
SMPprint(SMPmatrix *Matrix, char *Filename)
{ {
NG_IGNORE(File);
spPrint( Matrix, 0, 1, 1 );
if (Filename)
spFileMatrix(Matrix, Filename, "Circuit Matrix", 0, 1, 1 );
else
spPrint( Matrix, 0, 1, 1 );
} }
/* /*

2
src/spicelib/analysis/cktpzstr.c

@ -698,7 +698,7 @@ CKTpzRunTrial(CKTcircuit *ckt, PZtrial **new_trialp, PZtrial **set)
#ifdef PZDEBUG #ifdef PZDEBUG
DEBUG(3) { DEBUG(3) {
printf("Factored:\n"); printf("Factored:\n");
SMPprint(ckt->CKTmatrix, stdout);
SMPprint(ckt->CKTmatrix, NULL);
} }
#endif #endif
error = SMPcDProd(ckt->CKTmatrix, &new_trial->f_raw, error = SMPcDProd(ckt->CKTmatrix, &new_trial->f_raw,

4
src/spicelib/devices/txl/txlload.c

@ -48,7 +48,7 @@ TXLload(GENmodel *inModel, CKTcircuit *ckt)
/* debug /* debug
printf("before txlload\n"); printf("before txlload\n");
SMPprint(ckt->CKTmatrix, stdout);
SMPprint(ckt->CKTmatrix, NULL);
*/ */
h = ckt->CKTdelta; h = ckt->CKTdelta;
@ -254,7 +254,7 @@ TXLload(GENmodel *inModel, CKTcircuit *ckt)
/* debug /* debug
printf("after txlload\n"); printf("after txlload\n");
SMPprint(ckt->CKTmatrix, stdout);
SMPprint(ckt->CKTmatrix, NULL);
*/ */
return(OK); return(OK);

Loading…
Cancel
Save