AMSKernel.hh

Go to the documentation of this file.
00001 #ifndef AMSKERNEL_HH
00002 #define AMSKERNEL_HH
00003 
00004 // Copyright (c) 2002-2005 The University of Cincinnati.  All rights
00005 // reserved.
00006 
00007 // You may modify, distribute, and use the software contained in this
00008 // package under the terms of the "GNU LIBRARY GENERAL PUBLIC LICENSE"
00009 // version 2, June 1991. A copy of this license agreement can be found in
00010 // the file "LGPL", distributed with this archive.
00011 
00012 // Authors: Sameer Kher                    kherss@ececs.uc.edu
00013 //          Shriram Subramanian            subramsi@ececs.uc.edu
00014 
00015 #include <math.h>
00016 #include <list>
00017 #include "tyvis/VHDLKernel.hh"
00018 #include "tyvis/NodeList.hh"
00019 #include "tyvis/Constants.hh"
00020 #include "tyvis/ContributionNode.hh"
00021 #include "tyvis/AMSKernel_state.hh"
00022 extern "C" {
00023 #include "spmatrix.h"
00024 }
00025 
00026 using std::list;
00027 
00028 class component;
00029 class Quantity;
00030 
00032 class AMSKernel: public VHDLKernel {
00033 
00034 public:
00035   AMSKernel();
00036   virtual ~AMSKernel();
00037   
00038   /* Returns the pointer to the current set of equations in the analog
00039      process for the present time point. */
00040   list<component *> *getCurrentEquations() ;
00041   
00047   int matrixLoad(char *matrix);
00048       
00056   int iterate(int MaxIter, char *matrix);
00057       
00059   int getAnalysis() {
00060     return analysis;
00061   }
00062   
00064   int getMatrixSize() const;
00065   
00067   char* getDcMatrix();
00068 
00070   char* getTransientMatrix();
00071 
00078   int addNode(int nodeId, nodeConstants type);
00079   
00087   int addNodeCond(int nodeId, nodeConstants type);
00088   
00097   int addNodeCond(int nodeId, nodeConstants type,char* nam);
00098       
00105   int findNodeRHS(int nodeId);   
00106   
00109   void formCurrentEquations();
00110 
00112   void checkSolvability();
00113       
00116   void initialSettingUp();
00117   
00120   component* getComp() const;
00121   
00123   list<Quantity *>* getSetOfQuantities(); 
00124   
00126   void completeDynamicState();
00127   
00129   void definePointersAcross();
00130       
00132   void newSetBranch();
00133   
00140   int findDCOp(long firstMode, int iterLimit);
00141    
00143   virtual void setup(void)=0;   
00144   
00150   int newLoad(char *matrix);
00151 
00154   int newPointerAllocation();
00155   
00164   int newCheckCurrent(int posNode, int negNode, int indexVal);
00165   
00167   double* getRhs();
00168       
00170   double* getOldRhs();
00171       
00179   int newFindBranch(int posNode, int negNode);
00180       
00182   inline nodeList* getRhsNodes() const;
00183   
00185   void executeVHDL() {
00186     executeAnalogVHDL();
00187   }
00188   
00190   int executeAnalogVHDL() {  
00191     initialSettingUp();
00192     return 1;
00193   }
00194   
00198   void add(component* newcomp);
00199   
00201   virtual void printFunction() = 0;
00202       
00205   int getFreeLoadEqnCounter();
00206   
00209   void incrementFreeLoadEqnCounter();
00210 
00212   discreteTime getCurTime() ;
00213 
00219   int trunc(double *timeStep);
00220 
00228   void truncError(int qcap, double* timeStep);
00229 
00231   void updateQuantityValues(); 
00232 
00238   double getNewIterValueOfQuantity(Quantity *quantityPtr);
00239 
00245   double getPrevIterValueOfQuantity(Quantity *);
00246 
00258   int simulate(discreteTime endTime);
00259 
00267   double* getStateVector(int i);
00268 
00270   void createStates(); 
00271 
00273   int getStateLength();
00274 
00276   void incrementState();
00277 
00282   void copyStates(int from, int to);
00283 
00285   void rotateStates();
00286 
00296   int integrate(double* matrixValue,double* rhsValue, int stateIndex);
00297 
00299   long getMode();
00300 
00303   int compCoeff();
00304 
00305 protected:
00306   
00309   AMSKernel_state *getSolverState(){ return (AMSKernel_state *)getState(); }
00310 
00311 private:
00312 
00314   double pivotAbsTol;
00315 
00317   double pivotRelTol;
00318 
00321   nodeList* rhsNodes;
00322   
00324   char* dcMatrix;
00325 
00327   char* transientMatrix;
00328 
00330   enum {DC,TRANSIENT} analysis;
00331 
00333   int dcMaxIter;
00334 
00336   int transientMaxIter;
00337 
00339   component* comp;
00340 
00342   int noConv;
00343 
00345   int freeLoadEqnCounter;
00346 
00349   list<component *> *currentEquations;
00350 
00352   list<Quantity *> *setOfQuantities;
00353 
00355   int convergenceTest();
00356 
00358   double maxStep;
00359   
00361   double delMin;
00362 
00364   discreteTime startTime;
00365 
00367   bool setupFlag;
00368 
00371   int maxIntegOrder;
00372 
00374   double voltTol;
00375 
00377   double absTol;
00378 
00380   double relTol;
00381 
00383   double chgTol;
00384 
00386   double trTol;
00387 
00388 
00389 };
00390 #endif

Generated on Fri Mar 31 11:05:08 2006 for Tyvis by  doxygen 1.4.6