8 Star 28 Fork 2

Junruoyu-Zheng / Ligral

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
README_en.md 4.55 KB
Copy Edit Web IDE Raw Blame History
Junruoyu-Zheng authored 2021-02-22 19:07 . doc: rm command intro in readme

Ligral

LOGO

Ligral is a textual simulation language as an alternative to Simulink. The goal of ligral is to describe simulation models with a set of statements instead of a graphic implementation. The syntax of ligral ensures equally powerful ability of model description. Meanwhile, ligral provides various solvers to solve the ode problems given by the interpreter.

star

How to Install

We now have released v0.2.2 which is available at GitHub. Alternatively, you may also want to clone the source to your workspace and build ligral manually.

git clone https://github.com/jry-zheng/ligral.git
cd ligral
dotnet build
./bin/Debug/netcoreapp3.1/ligral

For detailed installation guide see Quick Start

Usage

The main function of ligral absolutely is run a simulation project. The project name, usually a .lig file name, should be the first positional parameter, like ligral path/file.lig. Besides, many parameters are supported:

Parameters Functions
[ProjectFileName] Simulation project name, usually a .lig file or a .lig.json file.
-s, --step-size [StepSize] The step size of simulation, works only with fixed step solvers.
-t, --stop-time [StopTime] The total time when the solver should stop.
-j, --json [bool]? Toggle the input to be .lig.json file. Ligral parse the project as .lig file if this is not toggled
-o, --output [Folder] Redirect the output folder.

The other commands that ligral supports include doc, trim, lin and exm, run ligral [command] --help to see more about the usage.

Dependency

If InnerPlotter is enabled and Scope or PhaseDiagram is used in your project, you need python 3 to let them work. Packages numpy、matplotlib、pandas are also required.

Examples

Following is a mass-spring-damper system implemented by ligral.

# Define a route named MassSpringDamper
route MassSpringDamper(m, k, d, x0, v0; F; x, v)
    F-k*x-d*v -> Gain{value:1/m} -> Integrator{initial:v0} -> v;
    v -> Integrator{initial:x0} -> x;
end

# Define a step signal
Step[F]{start:3, level:5};

# Instantiate a MassSpringDamper object
MassSpringDamper[sys]{m:0.1, k:10, d:0.3, x0:1, v0: 0};

# Link models
F -> sys;
sys:x[position] -> Scope;
(sys:x, sys:v[velocity]) -> PhaseDiagram;

# Configure the solver
conf step_size = 0.001;
conf stop_time = 10;

# Redirect the output folder
conf output_folder = 'out';

plots!!

More examples see examples.

Syntax

See detailed syntax in User Guide, which are written in Chinese currently. If you are interested in ligral but cannot read Chinese, please contact me via zhengjry@outlook.com. Followings are completed:

Development

We are working hard to write Development Guide. Now the followings are available with Chinese version.

If you found a bug please submit an issue.

Development plan:

  • Add unit test;
  • Add if-else, for, while statements and functions syntax for pre- and post-simulation process;
  • Unify the data signal to be a matrix, which means a scalar will be regarded as a 1 by 1 matrix;
  • Fix bugs
  • ...

Comment ( 0 )

Sign in for post a comment

C#
1
https://gitee.com/junruoyu-zheng/ligral.git
git@gitee.com:junruoyu-zheng/ligral.git
junruoyu-zheng
ligral
Ligral
dev

Search