jplus-0.4.7
yacts Class Reference

YACTS – yet another continuous time simulator. More...

#include <src/yacts.h>

Inheritance diagram for yacts:
Collaboration diagram for yacts:

Public Member Functions

 yacts ()
 Initializes YACTS.
 
bool init (std::istream &script)
 Load YACTS script.
 
 ~yacts ()
 Frees YACTS memory.
 
virtual void libInit ()
 Initializes YACTS library functions and makes them avaliable to J.
 
bool setOut (std::string newOut)
 Sets the name of output variable.
 
int REPL ()
 Enters read(stdin)-eval-print(stdout) loop until the end of stdin.
 
std::string getTrajectoryFilenameBase (std::string prefix)
 Computes trajectory filename base, using hash of "important" parts of yacts script.
 
bool initTrajectory (std::string prefix)
 Initializes ODE solver and the state either from the start of the problem or from the last saved trajectory frame.
 
int size ()
 Returns the number of computed frames in the current trajectory file.
 
bool setFrame (int iframe)
 Sets specified frame as "current", loads it.
 
bool hasNextFrameStored ()
 Returns true if the next frame is already in the trajectory file and does not have to be (and will not be) calculated.
 
bool nextFrame ()
 Advances to the next trajectory frame by computing it (if necessary) and saving (if computed).
 
std::string process ()
 Computes and returns the "OUT" variable, corresponding to the current frame.
 
- Public Member Functions inherited from jplus
 jplus ()
 initialize J+ engine with no script
 
bool init (std::istream &script)
 Load and pre-parse J+ script.
 
 ~jplus ()
 Free allocated memory.
 
bool set (std::string name, jarray data)
 Set value of the specified variable inside J+ environment, mark all dependent variables "dirty".
 
jarray get (std::string name)
 Perform all the necessary calculations to computate the specified variable, return its value in an array.
 
std::vector< std::string > getProgram (std::set< std::string > vars)
 Pull minimal set of J sentences for computing a given set of variables, assuming everything is "dirty".
 
std::vector< std::string > getProgram ()
 Pull all the sentences in J+ script.
 
- Public Member Functions inherited from jengine
 jengine ()
 Initializes J engine.
 
 ~jengine ()
 Frees J engine memory.
 
bool doJ (const std::string s)
 Executes J sentence.
 
const jarray get (const std::string name)
 Retrieves a named array from J.
 
bool set (const std::string name, jarray &value)
 Assigns J name to the specified array.
 
int getError ()
 J error code for the last unsuccessful operation.
 
bool ok ()
 Conveniently check that there was no error.
 
bool defVerb (std::string name, monad mf, dyad df, int mr=RMAX, int lr=RMAX, int rr=RMAX)
 Defines J verb, calling one (or both) of specified C++ functions.
 
bool defAdverb (std::string name, amonad mf, adyad df)
 defines J adverb, calling one (or both) of specified C++ functions.
 
bool defScript (std::string name, int type, std::string code, int mr=jengine::RMAX, int lr=jengine::RMAX, int rr=jengine::RMAX)
 Defines a J script, given by a (possibly multi-line) string.
 
bool isBuiltin (std::string name) const
 Checks if given name was defined via defScript.
 
std::set< std::string > getBuiltins () const
 Returns set of all names defined via defScript.
 
jarray::I PROLOG ()
 Returns the top of J garbage collection stack.
 
jarray::I EPILOG (jarray::I oldtop)
 Frees all memory, allocated since ttop was recorded.
 
voidEPILOG (jarray::I oldtop, void *hdr)
 Frees all memory, allocated since ttop was recorded.
 

Friends

int runTests ()
 

Additional Inherited Members

- Public Types inherited from jengine
typedef jarray(* monad) (jarray y)
 Pointer to function, implementing monadic variant of a verb.
 
typedef jarray(* dyad) (jarray x, jarray y)
 Pointer to function, implementing dyadic variant of a verb.
 
typedef jarray(* amonad) (monad um, dyad ud, jarray y)
 Pointer to function, implementing monadic variant of an adverb.
 
typedef jarray(* adyad) (monad um, dyad ud, jarray x, jarray y)
 Pointer to function, implementing dyadic variant of an adverb.
 
- Static Public Member Functions inherited from jengine
static void initJlibrary (std::ostream &)
 Loads and links J dynamic library, must be called once before this class is instantiated.
 
- Static Public Attributes inherited from jengine
static const int RMAX =10000
 Constant to denote the infinite rank.
 
- Protected Member Functions inherited from jengine
voidGA (const jarray::I t, const jarray::I n, const jarray::I r, const jarray::I *s)
 Allocates J array.
 
void FR (void *hdr)
 Frees J array memory.
 
- Protected Member Functions inherited from trjfile
std::streampos header_size ()
 header size on disk
 
std::streampos frame_size ()
 frame size on disk
 
void setHeader (int id, int neq)
 patch the header with new data
 
 trjfile ()
 Instantiates unopened trajectory file.
 
bool open (std::string path, bool create=true)
 Opens/creates trajectory and positions it before the last frame, or right after the header if trajectory was empty.
 
bool close ()
 Closes the trajectory.
 
bool good ()
 Checks that trajectory file is opened and properly positioned.
 
bool saveFrame (const int neq, const double &T, const double *data)
 Saves frame to the file at the current pos, appends if necessary.
 
bool hasNextFrame ()
 Checks if the file has next frame stored.
 
int getNEQ ()
 Get number of equations.
 
bool loadFrame (double &T, double *data)
 Load frame.
 
int size ()
 Get number of frames in the file.
 
bool toFrame (int frame)
 Position the file before the specified frame.
 
- Protected Attributes inherited from trjfile
int neq
 Number of equations in the system solved (frame size).
 
std::fstream trj
 Opened stream to the underlying file.
 

Detailed Description

YACTS – yet another continuous time simulator.

It uses J+ to specify a system of ODEs and Sundials library to solve them.

Constructor & Destructor Documentation

◆ yacts()

yacts::yacts ( )

Initializes YACTS.

◆ ~yacts()

yacts::~yacts ( )

Frees YACTS memory.

Member Function Documentation

◆ getTrajectoryFilenameBase()

std::string yacts::getTrajectoryFilenameBase ( std::string  prefix)

Computes trajectory filename base, using hash of "important" parts of yacts script.

Parameters
prefixtrajectory filename prefix.
Returns
trajectory filename base (without extension).

◆ hasNextFrameStored()

bool yacts::hasNextFrameStored ( )

Returns true if the next frame is already in the trajectory file and does not have to be (and will not be) calculated.

Returns
"true" if the next frame is in trajectory

◆ init()

bool yacts::init ( std::istream &  script)

Load YACTS script.

The script must define the following variables: T, double scalar – initial(first assignment), current and next frame time; S, double array – initial(first assignment) and current state; dSdT, double array – time derivative of state; OUT, character vector – textual rendering of the current state.

Parameters
scriptstream to load YACTS script from.

◆ initTrajectory()

bool yacts::initTrajectory ( std::string  prefix)

Initializes ODE solver and the state either from the start of the problem or from the last saved trajectory frame.

Parameters
prefixtrajectory filename prefix.
Returns
true upon success.

◆ libInit()

virtual void yacts::libInit ( )
virtual

Initializes YACTS library functions and makes them avaliable to J.

Reimplemented from jplus.

◆ nextFrame()

bool yacts::nextFrame ( )

Advances to the next trajectory frame by computing it (if necessary) and saving (if computed).

Returns
"true" if all is ok.

◆ process()

std::string yacts::process ( )

Computes and returns the "OUT" variable, corresponding to the current frame.

Returns
the computed output.

◆ REPL()

int yacts::REPL ( )

Enters read(stdin)-eval-print(stdout) loop until the end of stdin.

Returns
0.

◆ setFrame()

bool yacts::setFrame ( int  iframe)

Sets specified frame as "current", loads it.

Parameters
iframeindex of the frame to become current.
Returns
"true" upon success.

◆ setOut()

bool yacts::setOut ( std::string  newOut)

Sets the name of output variable.

Parameters
newOutnew output variable name.
Returns
"true" if success (the name was OK)

◆ size()

int yacts::size ( )

Returns the number of computed frames in the current trajectory file.

Returns
number of frames in the trajectory

Friends And Related Symbol Documentation

◆ runTests

int runTests ( )
friend

The documentation for this class was generated from the following file: