command mdump

This commit is contained in:
h_vogt 2012-02-19 10:23:56 +00:00
parent 862f10dce3
commit dffe4ed156
10 changed files with 89 additions and 24 deletions

View File

@ -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
* src/spicelib/devices/asrc/*.c,*.h,Makefile.am
* src/frontend/inpcom.c,

View File

@ -1,4 +1,5 @@
/* 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 <stdio.h>
@ -7,7 +8,9 @@
#include "control.h"
#include "ngspice/cpextern.h"
#include "ngspice/fteext.h"
#include "ngspice/smpdefs.h"
#include "ngspice/cktdefs.h"
#include "com_cdump.h"
static int indent;
@ -143,3 +146,29 @@ com_cdump(wordlist *wl)
dodump(c);
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;
}

View File

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

View File

@ -549,6 +549,10 @@ struct comm spcp_coms[] = {
{ 0, 0, 0, 0 }, E_DEFHMASK, 0, 0,
NULL,
": 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,
{ 0200000, 040000, 040000, 040000 }, E_DEFHMASK, 2, LOTS,
NULL,

View File

@ -70,6 +70,7 @@ CDHW*/
#include "ngspice/evtproto.h"
#include "ngspice/evtudn.h"
/* gtri - end - wbk - 5/20/91 - Add stuff for user-defined nodes */
#include "ngspice/mif.h"
#endif
/* 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
#include "ngspice/cktdefs.h"
@ -1499,12 +1508,12 @@ do {\
_foo(ckt->CKTirhs, double,size);
_foo(ckt->CKTirhsOld, 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);
@ -1520,8 +1529,9 @@ do {\
_foo(ft_curckt->ci_curTask->TSKname, char, -1);
{ /* 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;
// ckt->CKTcurJob = (&(ft_curckt->ci_curTask->taskOptions)) -> jobs;
@ -1536,6 +1546,14 @@ do {\
_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);
fclose(file);
@ -1656,12 +1674,12 @@ void com_savesnap(wordlist *wl)
_foo(ckt->CKTirhs,double,size);
_foo(ckt->CKTirhsOld,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 */
@ -1686,6 +1704,10 @@ void com_savesnap(wordlist *wl)
_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);

View File

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

View File

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

View File

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

View File

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

View File

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