/[ascend]/trunk/pygtk/variable.cpp
ViewVC logotype

Annotation of /trunk/pygtk/variable.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 669 - (hide annotations) (download) (as text)
Wed Jun 21 07:00:45 2006 UTC (13 years, 8 months ago) by johnpye
File MIME type: text/x-c++src
File size: 1290 byte(s)
Merged changes from DAE branch (revisions 702 to 819) back into trunk.
This adds the Integration API to the ASCEND solver (in base/generic).
Also provides pre-alpha support for 'IDA' from the SUNDIALS suite, a DAE solver.
Many other minor code clean-ups, including adoption of new 'ASC_NEW' and friends (to replace 'ascmalloc')
Added some very sketchy stuff providing 'DIFF(...)' syntax, although it is anticipated that this will be removed.
1 johnpye 132 #include <iostream>
2     #include <stdexcept>
3     using namespace std;
4    
5     #include "variable.h"
6 johnpye 237 #include "simulation.h"
7 johnpye 132
8 johnpye 237 extern "C"{
9     #include <utilities/ascConfig.h>
10     #include <utilities/ascMalloc.h>
11    
12     #include <general/dstring.h>
13     #include <compiler/compiler.h>
14     #include <compiler/symtab.h>
15     #include <compiler/instance_enum.h>
16     #include <compiler/instance_io.h>
17     }
18    
19 johnpye 132 Variable::Variable(){
20 johnpye 237 sim=NULL;
21     var=NULL;
22    
23     // default ctor
24 johnpye 132 }
25    
26 johnpye 237 Variable::Variable(const Variable &old) : sim(old.sim), var(old.var){
27     // copy ctor
28 johnpye 132 }
29    
30 johnpye 237 Variable::Variable(Simulation *sim, struct var_variable *var) : sim(sim), var(var){
31     if(var==NULL)throw runtime_error("Variable::Variable: var is NULL");
32 johnpye 132 }
33    
34 johnpye 237 const string
35     Variable::getName() const{
36 johnpye 669 if(var==NULL)throw runtime_error("Variable::Variable: var is NULL");
37 johnpye 237 char *n = WriteInstanceNameString((struct Instance *)var_instance(var),sim->getModel().getInternalType());
38 johnpye 669 if(n==NULL)throw runtime_error("Variable::Variable: n is NULL");
39 johnpye 237 string name = n;
40     ascfree(n);
41    
42 johnpye 132 return name;
43     }
44 johnpye 254
45     const double
46     Variable::getValue() const{
47     return var_value(var);
48     }
49 johnpye 283
50     const double
51     Variable::getNominal() const{
52     return var_nominal(var);
53     }
54    
55 johnpye 287 const double
56     Variable::getLowerBound() const{
57     return var_lower_bound(var);
58     }
59    
60     const double
61     Variable::getUpperBound() const{
62     return var_upper_bound(var);
63     }

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22