9 Star 46 Fork 4

Junruoyu-Zheng / Ligral

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README_en.md

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
  • ...

About

Ligral是一个基于文本的仿真语言,旨在替代 Simulink 进行仿真,通过与框图等效的文本语言描述仿真对象,并解释/编译而后求解。 expand collapse
Cancel

Releases (5)

All

Ligral

Contributors

All

Activities

Load More
can not load any more
C#
1
https://gitee.com/junruoyu-zheng/ligral.git
git@gitee.com:junruoyu-zheng/ligral.git
junruoyu-zheng
ligral
Ligral
dev

Search