Scripting

Scripting allows you to run tasks in 20-sim automatically using specialized scripting functions. With these functions you can open models, run simulations, change parameters, process the results and much more.

Videos

Watch the videos on scripting to get a quick overview.

 

Python

Python is a general-purpose high-level programming language with an emphasis on code readability and writing algorithms in fewer lines of code than other programming languages.20-sim scripting functions can be run from a python program. 20-sim scripting has been tested with the following versions of Python: Python 2.7.x, Python 3.4.x and Python 3.5.x (32-bit and 64-bit). All Python functions can be found here.

With the installation of 20-sim, you can optionally install the Python 3.4 package. This installation provides just enough support to get started with 20-sim scripting. However, it does not provide a development IDE or an extensive set of scientific and mathematical libraries.

20-sim scripting functions can be run as m-files in Matlab or GNU Octave. GNU Octave is a open source environment that allows you to run m-files similar to Matlab. If you don’t have a valid Matlab license, GNU Octave will be a useful alternative. All Octave functions can be found here.

Scripting Functions

Functions are available to open and simulate a 20-sim model, export parameters values to a 20-sim model, run simulations and store the results and much more. Combining multiple functions in m-files allows you to:

  1. read parameters from spreadsheets and load them into a 20-sim model,
  2. run calculations to deteremine parameter values and load them into a 20-sim model,
  3. run simulations and store the results on file,
  4. run simulations and perform calculations on the results,
  5. run multiple-scenario’s with 20-sim models,
  6. and more ..

Examples

20-sim comes with a set of example scripts:

  1. Read prarameters and run a simulation
  2. Model verification
  3. Compare simulation results
  4. Perform a Polynomial fit
  5. Create a bode plot out of simulation data
  6. Print to pdf-file
Example script with data import from Excel and bode plots generated from 20-sim simulation results.