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;
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");
}