testing
[gnucap-felix.git] / src / s__.h
blob537c8f11687e64ab21ee9b7a008dfb45307f31b4
1 /*$Id: s__.h,v 1.9 2009-12-16 17:22:07 felix Exp $ -*- C++ -*-
2 * Copyright (C) 2001 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *------------------------------------------------------------------
22 * base class for simulation methods
24 //testing=script,complete 2006.07.14
25 #ifndef S___H
26 #define S___H
27 #include "u_opt.h"
28 #include "c_comand.h"
29 /*--------------------------------------------------------------------------*/
30 class CARD;
31 class CARD_LIST;
32 class CS;
33 class PROBELIST;
34 class COMPONENT;
35 class WAVE;
36 /*--------------------------------------------------------------------------*/
37 class INTERFACE SIM : public CMD {
38 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
39 protected:
40 enum TRACE { // how much diagnostics to show
41 tNONE = 0, /* no extended diagnostics */
42 tUNDER , /* show underlying analysis, important pts only */
43 tALLTIME , /* show every time step, including hidden */
44 tGUESS , /* show guesses (from predictor) */
45 tREJECTED , /* show rejected time steps */
46 tITERATION , /* show every iteration, including nonconverged */
47 tVERBOSE , /* show extended diagnostics */
48 tMATRIX = 16, /* dump matrix. */
49 tDEBUG = 32
51 enum ALARM { // how much diagnostics to show
52 aNONE = 0, /* ignore range violations */
53 aREPORT = 1, /* report range violations */
54 aREDIR = 2, /* redirect to stderr */
55 aABORT = 4 /* abort simulation */
57 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
58 CARD_LIST* _scope;
59 OMSTREAM _out; /* places to send the results */
60 bool _dump_matrix;
61 public:
62 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
63 private:
64 const std::string long_label()const {unreachable(); return "";}
65 private:
66 virtual void setup(CS&) = 0;
67 virtual void sweep() = 0;
68 virtual void finish() {}
69 virtual bool is_step_rejected()const {return false;}
71 explicit SIM(const SIM&):CMD(),_scope(NULL) {unreachable(); incomplete();}
72 protected:
73 explicit SIM(): CMD(),_scope(NULL) {}
74 public:
75 ~SIM();
76 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
77 protected:
78 void command_base(CS&); /* s__init.cc */
79 bool common_options(CS& Cmd);
80 void reset_timers();
81 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
82 protected:
83 const PROBELIST& alarmlist()const; /* s__out.cc */
84 const PROBELIST& plotlist()const;
85 const PROBELIST& printlist()const;
86 const PROBELIST& storelist()const;
87 virtual void outdata(double);
88 virtual void head(double,double,const std::string&);
89 virtual void print_results(double);
90 virtual void alarm();
91 virtual void store_results(double);
92 virtual void expect_results(double);
93 protected: // hack?
94 WAVE** _wavep;
95 public:
96 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
97 protected: /* s__solve.cc */
98 bool solve(OPT::ITL,TRACE);
99 bool solve_with_homotopy(OPT::ITL,TRACE);
100 void advance_time();
101 protected:
102 void finish_building_evalq();
103 void set_flags();
104 void clear_arrays();
105 void evaluate_models();
106 void set_damp();
107 void load_matrix();
108 void solve_equations(TRACE);
110 /*--------------------------------------------------------------------------*/
111 /*--------------------------------------------------------------------------*/
112 #endif
113 // vim:ts=8:sw=2:noet: