Hi,
I want to know how start function code works in C-script block, this block is executed only once at the start of simulation right?
Can anyone direct me to the example , if any where the C-script block is executed only at the starting and its parameter values can be updated in the output function code.
Also could you please explain me the major time step and minor time steps . What are these? in Simple terms
I want to know how start function code works in C-script block, this block is executed only once at the start of simulation right?
Yes, the Start code is executed only once at the start of the simulation and is used for initializing the simulation. Internal state variables, for example, should be initialized here.
Can anyone direct me to the example , if any where the C-script block is executed only at the starting and its parameter values can be updated in the output function code.
One simple example is the “User Parameters” example in the C-Script documentation, attached here for your convenience, where the parameters are read in the Start function and persist during the output function. See: cscript_parameters.plecs (11.8 KB)
The C-Script block has extensive documentation in the PLECS manual including many minimal examples. There also is a tutorial available that describes the purpose of the various code functions as well. See - PLECS: Using the C-Script Block.
Also could you please explain me the major time step and minor time steps . What are these? in Simple terms
This has to due with the integration methods used by the solver. From the PLECS documentation:
“Depending on the solver algorithm, an integration step is performed in multiple stages - also called minor time steps - in order to increase the accuracy of the numerical integration. In each stage the solver calculates the derivatives at a different intermediate time. Since the derivative function of a block can depend on the block’s inputs - i.e. on other blocks’ outputs - the solver must first execute all output functions for that particular time.”
You can review the Runge-Kutta family of integration methods to better understand multistage integration methods.