Electrical RC circuit.
#if 0
Constant Uin(5);
#else
const double PI = 3.141592653589793;
Expression Uin( 0.5 * Sin(T*2*PI)+5 );
#endif
struct SystemRC {
Parameter R;
Parameter C;
Expression Current;
Integrator Uout;
SystemRC(Input Uin, double R0, double C0, double U0=0):
R(R0), C(C0), Current( (Uin-Uout)/R ),
Uout( Current/C, U0 ) {}
};
SystemRC rc1(Uin, 1000 , 0.001 );
void Sample1() {
Uin.Value(), rc1.Uout.Value(), rc1.Current.Value() );
}
Sampler s(Sample1, 0.01);
Print(
"# RC circuit simulation output\n");
}
virtual double Value()=0
get block output value this method should be defined in classes derived from aContiBlock
aContiBlock & T
simulation time block reference
void SetStep(double _dtmin, double _dtmax)
Set integration step interval.
void SetOutput(const char *name)
redirects Output(), Print() to file
void Run()
run simulation experiment
int Print(const char *fmt,...)
for Output methods, can be redirected
void Init(double t0, double t1=SIMLIB_MAXTIME)
Initialize simulator and model time.
Main SIMLIB/C++ interface.