NAMD
Macros | Functions | Variables
eabfTcl.C File Reference
#include "eabf.h"
#include "eabf1D.h"
#include "eabf2D.h"
#include "eabffunc.h"
#include <tcl.h>

Go to the source code of this file.

Macros

#define LINK_CPP
 

Functions

static int Tcl_startrun (ClientData useless, Tcl_Interp *stupidTcl, int argc, Tcl_Obj *CONST objv[])
 
static int Tcl_updaterun (ClientData useless, Tcl_Interp *stupidTcl, int argc, Tcl_Obj *CONST argv[])
 
static int Tcl_setcol (ClientData useless, Tcl_Interp *stupidTcl, int argc, Tcl_Obj *CONST argv[])
 
static int Tcl_mergefile (ClientData useless, Tcl_Interp *stupidTcl, int argc, Tcl_Obj *CONST objv[])
 
int Eabf_Init (Tcl_Interp *stupidTcl)
 
int eabf_static_init (Tcl_Interp *interp)
 

Variables

static eABFparse = 0
 

Macro Definition Documentation

#define LINK_CPP

Definition at line 14 of file eabfTcl.C.

Function Documentation

int Eabf_Init ( Tcl_Interp *  stupidTcl)

Definition at line 165 of file eabfTcl.C.

References Tcl_mergefile(), Tcl_setcol(), Tcl_startrun(), and Tcl_updaterun().

Referenced by eabf_static_init().

166 {
167  // create Tcl process "startrun" and "updaterun"
168  Tcl_CreateObjCommand(stupidTcl, "startrun", Tcl_startrun, (ClientData)0, (Tcl_CmdDeleteProc*)0);
169  Tcl_CreateObjCommand(stupidTcl, "updaterun", Tcl_updaterun, (ClientData)0, (Tcl_CmdDeleteProc*)0);
170  Tcl_CreateObjCommand(stupidTcl, "mergefile", Tcl_mergefile, (ClientData)0, (Tcl_CmdDeleteProc*)0);
171  Tcl_CreateObjCommand(stupidTcl, "setcol", Tcl_setcol, (ClientData)0, (Tcl_CmdDeleteProc*)0);
172  Tcl_PkgProvide(stupidTcl, "Eabf", "1.0.0");
173 
174  Tcl_Eval(stupidTcl, "puts \"eABF [package require Eabf]\"");
175 
176  return TCL_OK;
177 }
static int Tcl_startrun(ClientData useless, Tcl_Interp *stupidTcl, int argc, Tcl_Obj *CONST objv[])
Definition: eabfTcl.C:34
static int Tcl_updaterun(ClientData useless, Tcl_Interp *stupidTcl, int argc, Tcl_Obj *CONST argv[])
Definition: eabfTcl.C:84
static int Tcl_mergefile(ClientData useless, Tcl_Interp *stupidTcl, int argc, Tcl_Obj *CONST objv[])
Definition: eabfTcl.C:105
static int Tcl_setcol(ClientData useless, Tcl_Interp *stupidTcl, int argc, Tcl_Obj *CONST argv[])
Definition: eabfTcl.C:92
int eabf_static_init ( Tcl_Interp *  interp)

Definition at line 179 of file eabfTcl.C.

References Eabf_Init().

Referenced by ScriptTcl::ScriptTcl(), and ScriptTcl::tclsh().

179  {
180  Tcl_StaticPackage(0,"Eabf",Eabf_Init,0);
181  return Tcl_Eval(interp,"package ifneeded Eabf 1.0.0 {load {} Eabf}");
182 }
int Eabf_Init(Tcl_Interp *stupidTcl)
Definition: eabfTcl.C:165
static int Tcl_mergefile ( ClientData  useless,
Tcl_Interp *  stupidTcl,
int  argc,
Tcl_Obj *CONST  objv[] 
)
static

Definition at line 105 of file eabfTcl.C.

References eabffunc::chartodouble(), eabffunc::chartoint(), and eABF::mergefile().

Referenced by Eabf_Init().

106 {
107  std::string* argv = new std::string[argc];
108  // the last objv is the dimension of free-energy surface
109  for (int i = 0; i < argc; i++)
110  {
111  argv[i] = Tcl_GetString(objv[i]);
112  }
113 
114  // 1D eABF
115  if (eabffunc::chartoint(argv[1]) == 1)
116  {
117  parse = new eABF1D(eabffunc::chartodouble(argv[2]), // lowerboundary
118  eabffunc::chartodouble(argv[3]), // upperboundary
119  eabffunc::chartodouble(argv[4]), // width
120  0, //krestr
121  std::string(argv[5]), // outputfile
122  0, // outputfreq
123  0, // restart
124  "", // inputfile
125  0, // outputgrad
126  0, // gradfreq
127  0); // temperature
128 
129  // merge file
130  for (int i = 6; i < argc; i++)
131  {
132  parse->mergefile(argv[i], std::string(argv[5]));
133  }
134  }
135 
136  if (eabffunc::chartoint(argv[1]) == 2)
137  {
138  parse = new eABF2D(eabffunc::chartodouble(argv[2]), // lowerboundary
139  eabffunc::chartodouble(argv[3]), // upperboundary
140  eabffunc::chartodouble(argv[4]), // width
141  0, //krestr
142  eabffunc::chartodouble(argv[5]), // lowerboundary2
143  eabffunc::chartodouble(argv[6]), // upperboundary2
144  eabffunc::chartodouble(argv[7]), // width2
145  0, //krestr2
146  std::string(argv[8]), // outputfile
147  0, // outputfreq
148  0, // restart
149  "", // inputfile
150  0, // outputgrad
151  0, // gradfreq
152  0); //temperature
153 
154  // merge file
155  for (int i = 9; i < argc; i++)
156  {
157  parse->mergefile(argv[i], std::string(argv[8]));
158  }
159  }
160 
161  delete[] argv;
162  return TCL_OK;
163 }
Definition: eabf2D.h:23
bool mergefile(const std::string &inputname, const std::string &outputname)
Definition: eabf.h:39
int chartoint(const std::string &c)
Definition: eabffunc.C:48
double chartodouble(const std::string &c)
Definition: eabffunc.C:57
Definition: eabf1D.h:23
static eABF * parse
Definition: eabfTcl.C:31
static int Tcl_setcol ( ClientData  useless,
Tcl_Interp *  stupidTcl,
int  argc,
Tcl_Obj *CONST  argv[] 
)
static

Definition at line 92 of file eabfTcl.C.

References eabffunc::chartoint(), and eABF::setcolumn().

Referenced by Eabf_Init().

93 {
94  std::vector<int> cols;
95  for (int i = 1; i<argc; i++)
96  {
97  cols.push_back(eabffunc::chartoint(Tcl_GetString(argv[i])));
98  }
99  parse->setcolumn(cols);
100  return TCL_OK;
101 }
int chartoint(const std::string &c)
Definition: eabffunc.C:48
bool setcolumn(std::vector< int > col)
Definition: eabf.h:52
static eABF * parse
Definition: eabfTcl.C:31
static int Tcl_startrun ( ClientData  useless,
Tcl_Interp *  stupidTcl,
int  argc,
Tcl_Obj *CONST  objv[] 
)
static

Definition at line 34 of file eabfTcl.C.

References eabffunc::chartodouble(), and eabffunc::chartoint().

Referenced by Eabf_Init().

35 {
36  std::string* argv = new std::string[argc];
37  // the last objv is the dimension of free-energy surface
38  for(int i=0; i<argc; i++)
39  {
40  argv[i] = Tcl_GetString(objv[i]);
41  }
42 
43  // 1D eABF
44  if (eabffunc::chartoint(argv[argc - 1]) == 1)
45  {
46  parse = new eABF1D(eabffunc::chartodouble(argv[1]), // lowerboundary
47  eabffunc::chartodouble(argv[2]), // upperboundary
48  eabffunc::chartodouble(argv[3]), // width
49  eabffunc::chartodouble(argv[4]), //krestr
50  std::string(argv[5]), // outputfile
51  eabffunc::chartoint(argv[6]), // outputfreq
52  bool(eabffunc::chartoint(argv[7])), // restart
53  std::string(argv[8]), // inputfile
54  bool(eabffunc::chartoint(argv[9])), // outputgrad
55  eabffunc::chartoint(argv[10]), // gradfreq
56  eabffunc::chartodouble(argv[11])); // temperature
57  }
58 
59  // 2D eABF
60  if (eabffunc::chartoint(argv[argc - 1]) == 2)
61  {
62  parse = new eABF2D(eabffunc::chartodouble(argv[1]), // lowerboundary
63  eabffunc::chartodouble(argv[2]), // upperboundary
64  eabffunc::chartodouble(argv[3]), // width
65  eabffunc::chartodouble(argv[4]), // krestr
66  eabffunc::chartodouble(argv[5]), // lowerboundary2
67  eabffunc::chartodouble(argv[6]), // upperboundary2
68  eabffunc::chartodouble(argv[7]), // width2
69  eabffunc::chartodouble(argv[8]), // krestr2
70  std::string(argv[9]), // outputfile
71  eabffunc::chartoint(argv[10]), // outputfreq
72  bool(eabffunc::chartoint(argv[11])), // restart
73  std::string(argv[12]), // inputfile
74  bool(eabffunc::chartoint(argv[13])), // outputgrad
75  eabffunc::chartoint(argv[14]), // gradfreq
76  eabffunc::chartodouble(argv[15])); // temperature
77  }
78 
79  delete[] argv;
80  return TCL_OK;
81 }
Definition: eabf2D.h:23
int chartoint(const std::string &c)
Definition: eabffunc.C:48
double chartodouble(const std::string &c)
Definition: eabffunc.C:57
Definition: eabf1D.h:23
static eABF * parse
Definition: eabfTcl.C:31
static int Tcl_updaterun ( ClientData  useless,
Tcl_Interp *  stupidTcl,
int  argc,
Tcl_Obj *CONST  argv[] 
)
static

Definition at line 84 of file eabfTcl.C.

References eABF::update().

Referenced by Eabf_Init().

85 {
86  std::string colvar = Tcl_GetString(argv[1]);
87  parse->update(colvar);
88  return TCL_OK;
89 }
virtual bool update(const std::string &)=0
static eABF * parse
Definition: eabfTcl.C:31

Variable Documentation

eABF* parse = 0
static

Definition at line 31 of file eabfTcl.C.