Qucs-core  0.0.19
e_trsolver.h
Go to the documentation of this file.
00001 /*
00002  * e_trsolver.h - transient solver external interface class definitions
00003  *
00004  * Copyright (C) 2004, 2005, 2006, 2007, 2008 Stefan Jahn <stefan@lkcc.org>
00005  *
00006  * This is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2, or (at your option)
00009  * any later version.
00010  *
00011  * This software is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this package; see the file COPYING.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  * $Id$
00022  *
00023  */
00024 
00034 #ifndef __E_TRSOLVER_H__
00035 #define __E_TRSOLVER_H__
00036 
00037 #include "qucs_interface.h"
00038 #include "trsolver.h"
00039 #include <vector>
00040 
00041 namespace qucs {
00042 
00055 class e_trsolver : public trsolver
00056 {
00057 public:
00058     ACREATOR (e_trsolver);
00059     //e_trsolver ();
00060     e_trsolver (char *);
00061     e_trsolver (e_trsolver &);
00062     ~e_trsolver ();
00063 
00064     int init (nr_double_t, nr_double_t, int);
00065 //    int finish ();
00066     bool isExternal() { return true; };
00067 
00068 public:
00069 
00070     int stepsolve_sync (nr_double_t synctime);
00071     void acceptstep_sync (void);
00072     int stepsolve_async (nr_double_t steptime);
00073     void acceptstep_async (void);
00074     void rejectstep_async (void);
00075     void getsolution (double *);
00076 
00099     int setECVSVoltage(char * ecvsname, nr_double_t V);
00100 
00102     int getJacRows ();
00103 
00105     int getJacCols ();
00106 
00113     void getJacData (int r, int c, nr_double_t& data);
00114 
00125     int getNodeV (char * label, nr_double_t& nodeV);
00126 
00137     int getVProbeV (char * probename, nr_double_t& probeV);
00138 
00149     int getIProbeI (char * probename, nr_double_t& probeI);
00150 
00151     // debugging functions
00152     void debug (void);
00153     void printx (void);
00154 
00169     void (*messagefcn)(int level, const char * format, ...);
00170 
00171 private:
00172 
00173     int MaxIterations;
00174     nr_double_t reltol;
00175     nr_double_t abstol;
00176     nr_double_t vntol;
00177     nr_double_t time;
00178     nr_double_t saveCurrent;
00179     nr_double_t lastsynctime;
00180     int running;
00181     int rejected;
00182     int convError;
00183 
00184     void initETR (nr_double_t start, nr_double_t, int);
00185     void truncateHistory (nr_double_t);
00186     void updateExternalInterpTime(nr_double_t);
00187     void storeHistoryAges (void);
00188     void updateHistoryAges(nr_double_t);
00189 
00190 //    int solve_nonlinear_step (void);
00191     void adjustDelta_sync (nr_double_t);
00192 
00193     // Asynchronous specific items
00194 
00195     // For going back in history of a solution after multiple
00196     // solution steps
00197     std::vector<nr_double_t> initialhistages;
00198     tvector<nr_double_t> * lastsolution[8];
00199     nr_double_t lastasynctime;
00200     nr_double_t lastdeltas[8];
00201     nr_double_t lastdelta;
00202     // restores the solver to an earlier stored state, used
00203     // when an asynchronous major step is rejected by the
00204     // parent process
00205     void restoreSolution (void);
00206     void copySolution (tvector<nr_double_t> * [8], tvector<nr_double_t> * [8]);
00207     void fillLastSolution (tvector<nr_double_t> * );
00208 };
00209 
00210 } // namespace qucs
00211 
00212 #endif /* __e_trsolver_H__ */
00213