chore: 添加虚拟环境到仓库
- 添加 backend_service/venv 虚拟环境 - 包含所有Python依赖包 - 注意:虚拟环境约393MB,包含12655个文件
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
grammar Autolev;
|
||||
|
||||
options {
|
||||
language = Python3;
|
||||
}
|
||||
|
||||
prog: stat+;
|
||||
|
||||
stat: varDecl
|
||||
| functionCall
|
||||
| codeCommands
|
||||
| massDecl
|
||||
| inertiaDecl
|
||||
| assignment
|
||||
| settings
|
||||
;
|
||||
|
||||
assignment: vec equals expr #vecAssign
|
||||
| ID '[' index ']' equals expr #indexAssign
|
||||
| ID diff? equals expr #regularAssign;
|
||||
|
||||
equals: ('='|'+='|'-='|':='|'*='|'/='|'^=');
|
||||
|
||||
index: expr (',' expr)* ;
|
||||
|
||||
diff: ('\'')+;
|
||||
|
||||
functionCall: ID '(' (expr (',' expr)*)? ')'
|
||||
| (Mass|Inertia) '(' (ID (',' ID)*)? ')';
|
||||
|
||||
varDecl: varType varDecl2 (',' varDecl2)*;
|
||||
|
||||
varType: Newtonian|Frames|Bodies|Particles|Points|Constants
|
||||
| Specifieds|Imaginary|Variables ('\'')*|MotionVariables ('\'')*;
|
||||
|
||||
varDecl2: ID ('{' INT ',' INT '}')? (('{' INT ':' INT (',' INT ':' INT)* '}'))? ('{' INT '}')? ('+'|'-')? ('\'')* ('=' expr)?;
|
||||
|
||||
ranges: ('{' INT ':' INT (',' INT ':' INT)* '}');
|
||||
|
||||
massDecl: Mass massDecl2 (',' massDecl2)*;
|
||||
|
||||
massDecl2: ID '=' expr;
|
||||
|
||||
inertiaDecl: Inertia ID ('(' ID ')')? (',' expr)+;
|
||||
|
||||
matrix: '[' expr ((','|';') expr)* ']';
|
||||
matrixInOutput: (ID (ID '=' (FLOAT|INT)?))|FLOAT|INT;
|
||||
|
||||
codeCommands: units
|
||||
| inputs
|
||||
| outputs
|
||||
| codegen
|
||||
| commands;
|
||||
|
||||
settings: ID (EXP|ID|FLOAT|INT)?;
|
||||
|
||||
units: UnitSystem ID (',' ID)*;
|
||||
inputs: Input inputs2 (',' inputs2)*;
|
||||
id_diff: ID diff?;
|
||||
inputs2: id_diff '=' expr expr?;
|
||||
outputs: Output outputs2 (',' outputs2)*;
|
||||
outputs2: expr expr?;
|
||||
codegen: ID functionCall ('['matrixInOutput (',' matrixInOutput)*']')? ID'.'ID;
|
||||
|
||||
commands: Save ID'.'ID
|
||||
| Encode ID (',' ID)*;
|
||||
|
||||
vec: ID ('>')+
|
||||
| '0>'
|
||||
| '1>>';
|
||||
|
||||
expr: expr '^'<assoc=right> expr # Exponent
|
||||
| expr ('*'|'/') expr # MulDiv
|
||||
| expr ('+'|'-') expr # AddSub
|
||||
| EXP # exp
|
||||
| '-' expr # negativeOne
|
||||
| FLOAT # float
|
||||
| INT # int
|
||||
| ID('\'')* # id
|
||||
| vec # VectorOrDyadic
|
||||
| ID '['expr (',' expr)* ']' # Indexing
|
||||
| functionCall # function
|
||||
| matrix # matrices
|
||||
| '(' expr ')' # parens
|
||||
| expr '=' expr # idEqualsExpr
|
||||
| expr ':' expr # colon
|
||||
| ID? ranges ('\'')* # rangess
|
||||
;
|
||||
|
||||
// These are to take care of the case insensitivity of Autolev.
|
||||
Mass: ('M'|'m')('A'|'a')('S'|'s')('S'|'s');
|
||||
Inertia: ('I'|'i')('N'|'n')('E'|'e')('R'|'r')('T'|'t')('I'|'i')('A'|'a');
|
||||
Input: ('I'|'i')('N'|'n')('P'|'p')('U'|'u')('T'|'t')('S'|'s')?;
|
||||
Output: ('O'|'o')('U'|'u')('T'|'t')('P'|'p')('U'|'u')('T'|'t');
|
||||
Save: ('S'|'s')('A'|'a')('V'|'v')('E'|'e');
|
||||
UnitSystem: ('U'|'u')('N'|'n')('I'|'i')('T'|'t')('S'|'s')('Y'|'y')('S'|'s')('T'|'t')('E'|'e')('M'|'m');
|
||||
Encode: ('E'|'e')('N'|'n')('C'|'c')('O'|'o')('D'|'d')('E'|'e');
|
||||
Newtonian: ('N'|'n')('E'|'e')('W'|'w')('T'|'t')('O'|'o')('N'|'n')('I'|'i')('A'|'a')('N'|'n');
|
||||
Frames: ('F'|'f')('R'|'r')('A'|'a')('M'|'m')('E'|'e')('S'|'s')?;
|
||||
Bodies: ('B'|'b')('O'|'o')('D'|'d')('I'|'i')('E'|'e')('S'|'s')?;
|
||||
Particles: ('P'|'p')('A'|'a')('R'|'r')('T'|'t')('I'|'i')('C'|'c')('L'|'l')('E'|'e')('S'|'s')?;
|
||||
Points: ('P'|'p')('O'|'o')('I'|'i')('N'|'n')('T'|'t')('S'|'s')?;
|
||||
Constants: ('C'|'c')('O'|'o')('N'|'n')('S'|'s')('T'|'t')('A'|'a')('N'|'n')('T'|'t')('S'|'s')?;
|
||||
Specifieds: ('S'|'s')('P'|'p')('E'|'e')('C'|'c')('I'|'i')('F'|'f')('I'|'i')('E'|'e')('D'|'d')('S'|'s')?;
|
||||
Imaginary: ('I'|'i')('M'|'m')('A'|'a')('G'|'g')('I'|'i')('N'|'n')('A'|'a')('R'|'r')('Y'|'y');
|
||||
Variables: ('V'|'v')('A'|'a')('R'|'r')('I'|'i')('A'|'a')('B'|'b')('L'|'l')('E'|'e')('S'|'s')?;
|
||||
MotionVariables: ('M'|'m')('O'|'o')('T'|'t')('I'|'i')('O'|'o')('N'|'n')('V'|'v')('A'|'a')('R'|'r')('I'|'i')('A'|'a')('B'|'b')('L'|'l')('E'|'e')('S'|'s')?;
|
||||
|
||||
fragment DIFF: ('\'')*;
|
||||
fragment DIGIT: [0-9];
|
||||
INT: [0-9]+ ; // match integers
|
||||
FLOAT: DIGIT+ '.' DIGIT*
|
||||
| '.' DIGIT+;
|
||||
EXP: FLOAT 'E' INT
|
||||
| FLOAT 'E' '-' INT;
|
||||
LINE_COMMENT : '%' .*? '\r'? '\n' -> skip ;
|
||||
ID: [a-zA-Z][a-zA-Z0-9_]*;
|
||||
WS: [ \t\r\n&]+ -> skip ; // toss out whitespace
|
||||
@@ -0,0 +1,97 @@
|
||||
from sympy.external import import_module
|
||||
from sympy.utilities.decorator import doctest_depends_on
|
||||
|
||||
@doctest_depends_on(modules=('antlr4',))
|
||||
def parse_autolev(autolev_code, include_numeric=False):
|
||||
"""Parses Autolev code (version 4.1) to SymPy code.
|
||||
|
||||
Parameters
|
||||
=========
|
||||
autolev_code : Can be an str or any object with a readlines() method (such as a file handle or StringIO).
|
||||
include_numeric : boolean, optional
|
||||
If True NumPy, PyDy, or other numeric code is included for numeric evaluation lines in the Autolev code.
|
||||
|
||||
Returns
|
||||
=======
|
||||
sympy_code : str
|
||||
Equivalent SymPy and/or numpy/pydy code as the input code.
|
||||
|
||||
|
||||
Example (Double Pendulum)
|
||||
=========================
|
||||
>>> my_al_text = ("MOTIONVARIABLES' Q{2}', U{2}'",
|
||||
... "CONSTANTS L,M,G",
|
||||
... "NEWTONIAN N",
|
||||
... "FRAMES A,B",
|
||||
... "SIMPROT(N, A, 3, Q1)",
|
||||
... "SIMPROT(N, B, 3, Q2)",
|
||||
... "W_A_N>=U1*N3>",
|
||||
... "W_B_N>=U2*N3>",
|
||||
... "POINT O",
|
||||
... "PARTICLES P,R",
|
||||
... "P_O_P> = L*A1>",
|
||||
... "P_P_R> = L*B1>",
|
||||
... "V_O_N> = 0>",
|
||||
... "V2PTS(N, A, O, P)",
|
||||
... "V2PTS(N, B, P, R)",
|
||||
... "MASS P=M, R=M",
|
||||
... "Q1' = U1",
|
||||
... "Q2' = U2",
|
||||
... "GRAVITY(G*N1>)",
|
||||
... "ZERO = FR() + FRSTAR()",
|
||||
... "KANE()",
|
||||
... "INPUT M=1,G=9.81,L=1",
|
||||
... "INPUT Q1=.1,Q2=.2,U1=0,U2=0",
|
||||
... "INPUT TFINAL=10, INTEGSTP=.01",
|
||||
... "CODE DYNAMICS() some_filename.c")
|
||||
>>> my_al_text = '\\n'.join(my_al_text)
|
||||
>>> from sympy.parsing.autolev import parse_autolev
|
||||
>>> print(parse_autolev(my_al_text, include_numeric=True))
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
<BLANKLINE>
|
||||
q1, q2, u1, u2 = _me.dynamicsymbols('q1 q2 u1 u2')
|
||||
q1_d, q2_d, u1_d, u2_d = _me.dynamicsymbols('q1_ q2_ u1_ u2_', 1)
|
||||
l, m, g = _sm.symbols('l m g', real=True)
|
||||
frame_n = _me.ReferenceFrame('n')
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
frame_b = _me.ReferenceFrame('b')
|
||||
frame_a.orient(frame_n, 'Axis', [q1, frame_n.z])
|
||||
frame_b.orient(frame_n, 'Axis', [q2, frame_n.z])
|
||||
frame_a.set_ang_vel(frame_n, u1*frame_n.z)
|
||||
frame_b.set_ang_vel(frame_n, u2*frame_n.z)
|
||||
point_o = _me.Point('o')
|
||||
particle_p = _me.Particle('p', _me.Point('p_pt'), _sm.Symbol('m'))
|
||||
particle_r = _me.Particle('r', _me.Point('r_pt'), _sm.Symbol('m'))
|
||||
particle_p.point.set_pos(point_o, l*frame_a.x)
|
||||
particle_r.point.set_pos(particle_p.point, l*frame_b.x)
|
||||
point_o.set_vel(frame_n, 0)
|
||||
particle_p.point.v2pt_theory(point_o,frame_n,frame_a)
|
||||
particle_r.point.v2pt_theory(particle_p.point,frame_n,frame_b)
|
||||
particle_p.mass = m
|
||||
particle_r.mass = m
|
||||
force_p = particle_p.mass*(g*frame_n.x)
|
||||
force_r = particle_r.mass*(g*frame_n.x)
|
||||
kd_eqs = [q1_d - u1, q2_d - u2]
|
||||
forceList = [(particle_p.point,particle_p.mass*(g*frame_n.x)), (particle_r.point,particle_r.mass*(g*frame_n.x))]
|
||||
kane = _me.KanesMethod(frame_n, q_ind=[q1,q2], u_ind=[u1, u2], kd_eqs = kd_eqs)
|
||||
fr, frstar = kane.kanes_equations([particle_p, particle_r], forceList)
|
||||
zero = fr+frstar
|
||||
from pydy.system import System
|
||||
sys = System(kane, constants = {l:1, m:1, g:9.81},
|
||||
specifieds={},
|
||||
initial_conditions={q1:.1, q2:.2, u1:0, u2:0},
|
||||
times = _np.linspace(0.0, 10, 10/.01))
|
||||
<BLANKLINE>
|
||||
y=sys.integrate()
|
||||
<BLANKLINE>
|
||||
"""
|
||||
|
||||
_autolev = import_module(
|
||||
'sympy.parsing.autolev._parse_autolev_antlr',
|
||||
import_kwargs={'fromlist': ['X']})
|
||||
|
||||
if _autolev is not None:
|
||||
return _autolev.parse_autolev(autolev_code, include_numeric)
|
||||
@@ -0,0 +1,5 @@
|
||||
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
|
||||
#
|
||||
# Generated with antlr4
|
||||
# antlr4 is licensed under the BSD-3-Clause License
|
||||
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
|
||||
@@ -0,0 +1,253 @@
|
||||
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
|
||||
#
|
||||
# Generated with antlr4
|
||||
# antlr4 is licensed under the BSD-3-Clause License
|
||||
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
|
||||
from antlr4 import *
|
||||
from io import StringIO
|
||||
import sys
|
||||
if sys.version_info[1] > 5:
|
||||
from typing import TextIO
|
||||
else:
|
||||
from typing.io import TextIO
|
||||
|
||||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,0,49,393,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
|
||||
2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,
|
||||
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,
|
||||
19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,
|
||||
26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,
|
||||
32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,
|
||||
39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,
|
||||
45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,1,0,1,0,1,1,
|
||||
1,1,1,2,1,2,1,3,1,3,1,3,1,4,1,4,1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,7,
|
||||
1,7,1,7,1,8,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,
|
||||
13,1,14,1,14,1,15,1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,19,1,19,1,
|
||||
20,1,20,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,23,1,23,1,24,1,24,1,
|
||||
25,1,25,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,
|
||||
27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,3,28,184,8,28,1,29,1,29,1,
|
||||
29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,
|
||||
31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32,1,
|
||||
32,1,32,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,34,1,
|
||||
34,1,34,1,34,1,34,1,34,3,34,232,8,34,1,35,1,35,1,35,1,35,1,35,1,
|
||||
35,3,35,240,8,35,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,3,
|
||||
36,251,8,36,1,37,1,37,1,37,1,37,1,37,1,37,3,37,259,8,37,1,38,1,38,
|
||||
1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,270,8,38,1,39,1,39,1,39,
|
||||
1,39,1,39,1,39,1,39,1,39,1,39,1,39,3,39,282,8,39,1,40,1,40,1,40,
|
||||
1,40,1,40,1,40,1,40,1,40,1,40,1,40,1,41,1,41,1,41,1,41,1,41,1,41,
|
||||
1,41,1,41,1,41,3,41,303,8,41,1,42,1,42,1,42,1,42,1,42,1,42,1,42,
|
||||
1,42,1,42,1,42,1,42,1,42,1,42,1,42,1,42,3,42,320,8,42,1,43,5,43,
|
||||
323,8,43,10,43,12,43,326,9,43,1,44,1,44,1,45,4,45,331,8,45,11,45,
|
||||
12,45,332,1,46,4,46,336,8,46,11,46,12,46,337,1,46,1,46,5,46,342,
|
||||
8,46,10,46,12,46,345,9,46,1,46,1,46,4,46,349,8,46,11,46,12,46,350,
|
||||
3,46,353,8,46,1,47,1,47,1,47,1,47,1,47,1,47,1,47,1,47,1,47,3,47,
|
||||
364,8,47,1,48,1,48,5,48,368,8,48,10,48,12,48,371,9,48,1,48,3,48,
|
||||
374,8,48,1,48,1,48,1,48,1,48,1,49,1,49,5,49,382,8,49,10,49,12,49,
|
||||
385,9,49,1,50,4,50,388,8,50,11,50,12,50,389,1,50,1,50,1,369,0,51,
|
||||
1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,
|
||||
27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,
|
||||
49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,
|
||||
71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,0,89,0,91,44,
|
||||
93,45,95,46,97,47,99,48,101,49,1,0,24,2,0,77,77,109,109,2,0,65,65,
|
||||
97,97,2,0,83,83,115,115,2,0,73,73,105,105,2,0,78,78,110,110,2,0,
|
||||
69,69,101,101,2,0,82,82,114,114,2,0,84,84,116,116,2,0,80,80,112,
|
||||
112,2,0,85,85,117,117,2,0,79,79,111,111,2,0,86,86,118,118,2,0,89,
|
||||
89,121,121,2,0,67,67,99,99,2,0,68,68,100,100,2,0,87,87,119,119,2,
|
||||
0,70,70,102,102,2,0,66,66,98,98,2,0,76,76,108,108,2,0,71,71,103,
|
||||
103,1,0,48,57,2,0,65,90,97,122,4,0,48,57,65,90,95,95,97,122,4,0,
|
||||
9,10,13,13,32,32,38,38,410,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,
|
||||
7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,
|
||||
1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,
|
||||
1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,
|
||||
1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,
|
||||
1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,
|
||||
1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,
|
||||
1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,
|
||||
1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,91,
|
||||
1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,0,0,101,
|
||||
1,0,0,0,1,103,1,0,0,0,3,105,1,0,0,0,5,107,1,0,0,0,7,109,1,0,0,0,
|
||||
9,112,1,0,0,0,11,115,1,0,0,0,13,118,1,0,0,0,15,121,1,0,0,0,17,124,
|
||||
1,0,0,0,19,127,1,0,0,0,21,129,1,0,0,0,23,131,1,0,0,0,25,133,1,0,
|
||||
0,0,27,135,1,0,0,0,29,137,1,0,0,0,31,139,1,0,0,0,33,141,1,0,0,0,
|
||||
35,143,1,0,0,0,37,145,1,0,0,0,39,147,1,0,0,0,41,149,1,0,0,0,43,151,
|
||||
1,0,0,0,45,154,1,0,0,0,47,158,1,0,0,0,49,160,1,0,0,0,51,162,1,0,
|
||||
0,0,53,164,1,0,0,0,55,169,1,0,0,0,57,177,1,0,0,0,59,185,1,0,0,0,
|
||||
61,192,1,0,0,0,63,197,1,0,0,0,65,208,1,0,0,0,67,215,1,0,0,0,69,225,
|
||||
1,0,0,0,71,233,1,0,0,0,73,241,1,0,0,0,75,252,1,0,0,0,77,260,1,0,
|
||||
0,0,79,271,1,0,0,0,81,283,1,0,0,0,83,293,1,0,0,0,85,304,1,0,0,0,
|
||||
87,324,1,0,0,0,89,327,1,0,0,0,91,330,1,0,0,0,93,352,1,0,0,0,95,363,
|
||||
1,0,0,0,97,365,1,0,0,0,99,379,1,0,0,0,101,387,1,0,0,0,103,104,5,
|
||||
91,0,0,104,2,1,0,0,0,105,106,5,93,0,0,106,4,1,0,0,0,107,108,5,61,
|
||||
0,0,108,6,1,0,0,0,109,110,5,43,0,0,110,111,5,61,0,0,111,8,1,0,0,
|
||||
0,112,113,5,45,0,0,113,114,5,61,0,0,114,10,1,0,0,0,115,116,5,58,
|
||||
0,0,116,117,5,61,0,0,117,12,1,0,0,0,118,119,5,42,0,0,119,120,5,61,
|
||||
0,0,120,14,1,0,0,0,121,122,5,47,0,0,122,123,5,61,0,0,123,16,1,0,
|
||||
0,0,124,125,5,94,0,0,125,126,5,61,0,0,126,18,1,0,0,0,127,128,5,44,
|
||||
0,0,128,20,1,0,0,0,129,130,5,39,0,0,130,22,1,0,0,0,131,132,5,40,
|
||||
0,0,132,24,1,0,0,0,133,134,5,41,0,0,134,26,1,0,0,0,135,136,5,123,
|
||||
0,0,136,28,1,0,0,0,137,138,5,125,0,0,138,30,1,0,0,0,139,140,5,58,
|
||||
0,0,140,32,1,0,0,0,141,142,5,43,0,0,142,34,1,0,0,0,143,144,5,45,
|
||||
0,0,144,36,1,0,0,0,145,146,5,59,0,0,146,38,1,0,0,0,147,148,5,46,
|
||||
0,0,148,40,1,0,0,0,149,150,5,62,0,0,150,42,1,0,0,0,151,152,5,48,
|
||||
0,0,152,153,5,62,0,0,153,44,1,0,0,0,154,155,5,49,0,0,155,156,5,62,
|
||||
0,0,156,157,5,62,0,0,157,46,1,0,0,0,158,159,5,94,0,0,159,48,1,0,
|
||||
0,0,160,161,5,42,0,0,161,50,1,0,0,0,162,163,5,47,0,0,163,52,1,0,
|
||||
0,0,164,165,7,0,0,0,165,166,7,1,0,0,166,167,7,2,0,0,167,168,7,2,
|
||||
0,0,168,54,1,0,0,0,169,170,7,3,0,0,170,171,7,4,0,0,171,172,7,5,0,
|
||||
0,172,173,7,6,0,0,173,174,7,7,0,0,174,175,7,3,0,0,175,176,7,1,0,
|
||||
0,176,56,1,0,0,0,177,178,7,3,0,0,178,179,7,4,0,0,179,180,7,8,0,0,
|
||||
180,181,7,9,0,0,181,183,7,7,0,0,182,184,7,2,0,0,183,182,1,0,0,0,
|
||||
183,184,1,0,0,0,184,58,1,0,0,0,185,186,7,10,0,0,186,187,7,9,0,0,
|
||||
187,188,7,7,0,0,188,189,7,8,0,0,189,190,7,9,0,0,190,191,7,7,0,0,
|
||||
191,60,1,0,0,0,192,193,7,2,0,0,193,194,7,1,0,0,194,195,7,11,0,0,
|
||||
195,196,7,5,0,0,196,62,1,0,0,0,197,198,7,9,0,0,198,199,7,4,0,0,199,
|
||||
200,7,3,0,0,200,201,7,7,0,0,201,202,7,2,0,0,202,203,7,12,0,0,203,
|
||||
204,7,2,0,0,204,205,7,7,0,0,205,206,7,5,0,0,206,207,7,0,0,0,207,
|
||||
64,1,0,0,0,208,209,7,5,0,0,209,210,7,4,0,0,210,211,7,13,0,0,211,
|
||||
212,7,10,0,0,212,213,7,14,0,0,213,214,7,5,0,0,214,66,1,0,0,0,215,
|
||||
216,7,4,0,0,216,217,7,5,0,0,217,218,7,15,0,0,218,219,7,7,0,0,219,
|
||||
220,7,10,0,0,220,221,7,4,0,0,221,222,7,3,0,0,222,223,7,1,0,0,223,
|
||||
224,7,4,0,0,224,68,1,0,0,0,225,226,7,16,0,0,226,227,7,6,0,0,227,
|
||||
228,7,1,0,0,228,229,7,0,0,0,229,231,7,5,0,0,230,232,7,2,0,0,231,
|
||||
230,1,0,0,0,231,232,1,0,0,0,232,70,1,0,0,0,233,234,7,17,0,0,234,
|
||||
235,7,10,0,0,235,236,7,14,0,0,236,237,7,3,0,0,237,239,7,5,0,0,238,
|
||||
240,7,2,0,0,239,238,1,0,0,0,239,240,1,0,0,0,240,72,1,0,0,0,241,242,
|
||||
7,8,0,0,242,243,7,1,0,0,243,244,7,6,0,0,244,245,7,7,0,0,245,246,
|
||||
7,3,0,0,246,247,7,13,0,0,247,248,7,18,0,0,248,250,7,5,0,0,249,251,
|
||||
7,2,0,0,250,249,1,0,0,0,250,251,1,0,0,0,251,74,1,0,0,0,252,253,7,
|
||||
8,0,0,253,254,7,10,0,0,254,255,7,3,0,0,255,256,7,4,0,0,256,258,7,
|
||||
7,0,0,257,259,7,2,0,0,258,257,1,0,0,0,258,259,1,0,0,0,259,76,1,0,
|
||||
0,0,260,261,7,13,0,0,261,262,7,10,0,0,262,263,7,4,0,0,263,264,7,
|
||||
2,0,0,264,265,7,7,0,0,265,266,7,1,0,0,266,267,7,4,0,0,267,269,7,
|
||||
7,0,0,268,270,7,2,0,0,269,268,1,0,0,0,269,270,1,0,0,0,270,78,1,0,
|
||||
0,0,271,272,7,2,0,0,272,273,7,8,0,0,273,274,7,5,0,0,274,275,7,13,
|
||||
0,0,275,276,7,3,0,0,276,277,7,16,0,0,277,278,7,3,0,0,278,279,7,5,
|
||||
0,0,279,281,7,14,0,0,280,282,7,2,0,0,281,280,1,0,0,0,281,282,1,0,
|
||||
0,0,282,80,1,0,0,0,283,284,7,3,0,0,284,285,7,0,0,0,285,286,7,1,0,
|
||||
0,286,287,7,19,0,0,287,288,7,3,0,0,288,289,7,4,0,0,289,290,7,1,0,
|
||||
0,290,291,7,6,0,0,291,292,7,12,0,0,292,82,1,0,0,0,293,294,7,11,0,
|
||||
0,294,295,7,1,0,0,295,296,7,6,0,0,296,297,7,3,0,0,297,298,7,1,0,
|
||||
0,298,299,7,17,0,0,299,300,7,18,0,0,300,302,7,5,0,0,301,303,7,2,
|
||||
0,0,302,301,1,0,0,0,302,303,1,0,0,0,303,84,1,0,0,0,304,305,7,0,0,
|
||||
0,305,306,7,10,0,0,306,307,7,7,0,0,307,308,7,3,0,0,308,309,7,10,
|
||||
0,0,309,310,7,4,0,0,310,311,7,11,0,0,311,312,7,1,0,0,312,313,7,6,
|
||||
0,0,313,314,7,3,0,0,314,315,7,1,0,0,315,316,7,17,0,0,316,317,7,18,
|
||||
0,0,317,319,7,5,0,0,318,320,7,2,0,0,319,318,1,0,0,0,319,320,1,0,
|
||||
0,0,320,86,1,0,0,0,321,323,5,39,0,0,322,321,1,0,0,0,323,326,1,0,
|
||||
0,0,324,322,1,0,0,0,324,325,1,0,0,0,325,88,1,0,0,0,326,324,1,0,0,
|
||||
0,327,328,7,20,0,0,328,90,1,0,0,0,329,331,7,20,0,0,330,329,1,0,0,
|
||||
0,331,332,1,0,0,0,332,330,1,0,0,0,332,333,1,0,0,0,333,92,1,0,0,0,
|
||||
334,336,3,89,44,0,335,334,1,0,0,0,336,337,1,0,0,0,337,335,1,0,0,
|
||||
0,337,338,1,0,0,0,338,339,1,0,0,0,339,343,5,46,0,0,340,342,3,89,
|
||||
44,0,341,340,1,0,0,0,342,345,1,0,0,0,343,341,1,0,0,0,343,344,1,0,
|
||||
0,0,344,353,1,0,0,0,345,343,1,0,0,0,346,348,5,46,0,0,347,349,3,89,
|
||||
44,0,348,347,1,0,0,0,349,350,1,0,0,0,350,348,1,0,0,0,350,351,1,0,
|
||||
0,0,351,353,1,0,0,0,352,335,1,0,0,0,352,346,1,0,0,0,353,94,1,0,0,
|
||||
0,354,355,3,93,46,0,355,356,5,69,0,0,356,357,3,91,45,0,357,364,1,
|
||||
0,0,0,358,359,3,93,46,0,359,360,5,69,0,0,360,361,5,45,0,0,361,362,
|
||||
3,91,45,0,362,364,1,0,0,0,363,354,1,0,0,0,363,358,1,0,0,0,364,96,
|
||||
1,0,0,0,365,369,5,37,0,0,366,368,9,0,0,0,367,366,1,0,0,0,368,371,
|
||||
1,0,0,0,369,370,1,0,0,0,369,367,1,0,0,0,370,373,1,0,0,0,371,369,
|
||||
1,0,0,0,372,374,5,13,0,0,373,372,1,0,0,0,373,374,1,0,0,0,374,375,
|
||||
1,0,0,0,375,376,5,10,0,0,376,377,1,0,0,0,377,378,6,48,0,0,378,98,
|
||||
1,0,0,0,379,383,7,21,0,0,380,382,7,22,0,0,381,380,1,0,0,0,382,385,
|
||||
1,0,0,0,383,381,1,0,0,0,383,384,1,0,0,0,384,100,1,0,0,0,385,383,
|
||||
1,0,0,0,386,388,7,23,0,0,387,386,1,0,0,0,388,389,1,0,0,0,389,387,
|
||||
1,0,0,0,389,390,1,0,0,0,390,391,1,0,0,0,391,392,6,50,0,0,392,102,
|
||||
1,0,0,0,21,0,183,231,239,250,258,269,281,302,319,324,332,337,343,
|
||||
350,352,363,369,373,383,389,1,6,0,0
|
||||
]
|
||||
|
||||
class AutolevLexer(Lexer):
|
||||
|
||||
atn = ATNDeserializer().deserialize(serializedATN())
|
||||
|
||||
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
|
||||
|
||||
T__0 = 1
|
||||
T__1 = 2
|
||||
T__2 = 3
|
||||
T__3 = 4
|
||||
T__4 = 5
|
||||
T__5 = 6
|
||||
T__6 = 7
|
||||
T__7 = 8
|
||||
T__8 = 9
|
||||
T__9 = 10
|
||||
T__10 = 11
|
||||
T__11 = 12
|
||||
T__12 = 13
|
||||
T__13 = 14
|
||||
T__14 = 15
|
||||
T__15 = 16
|
||||
T__16 = 17
|
||||
T__17 = 18
|
||||
T__18 = 19
|
||||
T__19 = 20
|
||||
T__20 = 21
|
||||
T__21 = 22
|
||||
T__22 = 23
|
||||
T__23 = 24
|
||||
T__24 = 25
|
||||
T__25 = 26
|
||||
Mass = 27
|
||||
Inertia = 28
|
||||
Input = 29
|
||||
Output = 30
|
||||
Save = 31
|
||||
UnitSystem = 32
|
||||
Encode = 33
|
||||
Newtonian = 34
|
||||
Frames = 35
|
||||
Bodies = 36
|
||||
Particles = 37
|
||||
Points = 38
|
||||
Constants = 39
|
||||
Specifieds = 40
|
||||
Imaginary = 41
|
||||
Variables = 42
|
||||
MotionVariables = 43
|
||||
INT = 44
|
||||
FLOAT = 45
|
||||
EXP = 46
|
||||
LINE_COMMENT = 47
|
||||
ID = 48
|
||||
WS = 49
|
||||
|
||||
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
||||
|
||||
modeNames = [ "DEFAULT_MODE" ]
|
||||
|
||||
literalNames = [ "<INVALID>",
|
||||
"'['", "']'", "'='", "'+='", "'-='", "':='", "'*='", "'/='",
|
||||
"'^='", "','", "'''", "'('", "')'", "'{'", "'}'", "':'", "'+'",
|
||||
"'-'", "';'", "'.'", "'>'", "'0>'", "'1>>'", "'^'", "'*'", "'/'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>",
|
||||
"Mass", "Inertia", "Input", "Output", "Save", "UnitSystem",
|
||||
"Encode", "Newtonian", "Frames", "Bodies", "Particles", "Points",
|
||||
"Constants", "Specifieds", "Imaginary", "Variables", "MotionVariables",
|
||||
"INT", "FLOAT", "EXP", "LINE_COMMENT", "ID", "WS" ]
|
||||
|
||||
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6",
|
||||
"T__7", "T__8", "T__9", "T__10", "T__11", "T__12", "T__13",
|
||||
"T__14", "T__15", "T__16", "T__17", "T__18", "T__19",
|
||||
"T__20", "T__21", "T__22", "T__23", "T__24", "T__25",
|
||||
"Mass", "Inertia", "Input", "Output", "Save", "UnitSystem",
|
||||
"Encode", "Newtonian", "Frames", "Bodies", "Particles",
|
||||
"Points", "Constants", "Specifieds", "Imaginary", "Variables",
|
||||
"MotionVariables", "DIFF", "DIGIT", "INT", "FLOAT", "EXP",
|
||||
"LINE_COMMENT", "ID", "WS" ]
|
||||
|
||||
grammarFileName = "Autolev.g4"
|
||||
|
||||
def __init__(self, input=None, output:TextIO = sys.stdout):
|
||||
super().__init__(input, output)
|
||||
self.checkVersion("4.11.1")
|
||||
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
|
||||
self._actions = None
|
||||
self._predicates = None
|
||||
|
||||
|
||||
@@ -0,0 +1,421 @@
|
||||
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
|
||||
#
|
||||
# Generated with antlr4
|
||||
# antlr4 is licensed under the BSD-3-Clause License
|
||||
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
|
||||
from antlr4 import *
|
||||
if __name__ is not None and "." in __name__:
|
||||
from .autolevparser import AutolevParser
|
||||
else:
|
||||
from autolevparser import AutolevParser
|
||||
|
||||
# This class defines a complete listener for a parse tree produced by AutolevParser.
|
||||
class AutolevListener(ParseTreeListener):
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#prog.
|
||||
def enterProg(self, ctx:AutolevParser.ProgContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#prog.
|
||||
def exitProg(self, ctx:AutolevParser.ProgContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#stat.
|
||||
def enterStat(self, ctx:AutolevParser.StatContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#stat.
|
||||
def exitStat(self, ctx:AutolevParser.StatContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#vecAssign.
|
||||
def enterVecAssign(self, ctx:AutolevParser.VecAssignContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#vecAssign.
|
||||
def exitVecAssign(self, ctx:AutolevParser.VecAssignContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#indexAssign.
|
||||
def enterIndexAssign(self, ctx:AutolevParser.IndexAssignContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#indexAssign.
|
||||
def exitIndexAssign(self, ctx:AutolevParser.IndexAssignContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#regularAssign.
|
||||
def enterRegularAssign(self, ctx:AutolevParser.RegularAssignContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#regularAssign.
|
||||
def exitRegularAssign(self, ctx:AutolevParser.RegularAssignContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#equals.
|
||||
def enterEquals(self, ctx:AutolevParser.EqualsContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#equals.
|
||||
def exitEquals(self, ctx:AutolevParser.EqualsContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#index.
|
||||
def enterIndex(self, ctx:AutolevParser.IndexContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#index.
|
||||
def exitIndex(self, ctx:AutolevParser.IndexContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#diff.
|
||||
def enterDiff(self, ctx:AutolevParser.DiffContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#diff.
|
||||
def exitDiff(self, ctx:AutolevParser.DiffContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#functionCall.
|
||||
def enterFunctionCall(self, ctx:AutolevParser.FunctionCallContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#functionCall.
|
||||
def exitFunctionCall(self, ctx:AutolevParser.FunctionCallContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#varDecl.
|
||||
def enterVarDecl(self, ctx:AutolevParser.VarDeclContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#varDecl.
|
||||
def exitVarDecl(self, ctx:AutolevParser.VarDeclContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#varType.
|
||||
def enterVarType(self, ctx:AutolevParser.VarTypeContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#varType.
|
||||
def exitVarType(self, ctx:AutolevParser.VarTypeContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#varDecl2.
|
||||
def enterVarDecl2(self, ctx:AutolevParser.VarDecl2Context):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#varDecl2.
|
||||
def exitVarDecl2(self, ctx:AutolevParser.VarDecl2Context):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#ranges.
|
||||
def enterRanges(self, ctx:AutolevParser.RangesContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#ranges.
|
||||
def exitRanges(self, ctx:AutolevParser.RangesContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#massDecl.
|
||||
def enterMassDecl(self, ctx:AutolevParser.MassDeclContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#massDecl.
|
||||
def exitMassDecl(self, ctx:AutolevParser.MassDeclContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#massDecl2.
|
||||
def enterMassDecl2(self, ctx:AutolevParser.MassDecl2Context):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#massDecl2.
|
||||
def exitMassDecl2(self, ctx:AutolevParser.MassDecl2Context):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#inertiaDecl.
|
||||
def enterInertiaDecl(self, ctx:AutolevParser.InertiaDeclContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#inertiaDecl.
|
||||
def exitInertiaDecl(self, ctx:AutolevParser.InertiaDeclContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#matrix.
|
||||
def enterMatrix(self, ctx:AutolevParser.MatrixContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#matrix.
|
||||
def exitMatrix(self, ctx:AutolevParser.MatrixContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#matrixInOutput.
|
||||
def enterMatrixInOutput(self, ctx:AutolevParser.MatrixInOutputContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#matrixInOutput.
|
||||
def exitMatrixInOutput(self, ctx:AutolevParser.MatrixInOutputContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#codeCommands.
|
||||
def enterCodeCommands(self, ctx:AutolevParser.CodeCommandsContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#codeCommands.
|
||||
def exitCodeCommands(self, ctx:AutolevParser.CodeCommandsContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#settings.
|
||||
def enterSettings(self, ctx:AutolevParser.SettingsContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#settings.
|
||||
def exitSettings(self, ctx:AutolevParser.SettingsContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#units.
|
||||
def enterUnits(self, ctx:AutolevParser.UnitsContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#units.
|
||||
def exitUnits(self, ctx:AutolevParser.UnitsContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#inputs.
|
||||
def enterInputs(self, ctx:AutolevParser.InputsContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#inputs.
|
||||
def exitInputs(self, ctx:AutolevParser.InputsContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#id_diff.
|
||||
def enterId_diff(self, ctx:AutolevParser.Id_diffContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#id_diff.
|
||||
def exitId_diff(self, ctx:AutolevParser.Id_diffContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#inputs2.
|
||||
def enterInputs2(self, ctx:AutolevParser.Inputs2Context):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#inputs2.
|
||||
def exitInputs2(self, ctx:AutolevParser.Inputs2Context):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#outputs.
|
||||
def enterOutputs(self, ctx:AutolevParser.OutputsContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#outputs.
|
||||
def exitOutputs(self, ctx:AutolevParser.OutputsContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#outputs2.
|
||||
def enterOutputs2(self, ctx:AutolevParser.Outputs2Context):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#outputs2.
|
||||
def exitOutputs2(self, ctx:AutolevParser.Outputs2Context):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#codegen.
|
||||
def enterCodegen(self, ctx:AutolevParser.CodegenContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#codegen.
|
||||
def exitCodegen(self, ctx:AutolevParser.CodegenContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#commands.
|
||||
def enterCommands(self, ctx:AutolevParser.CommandsContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#commands.
|
||||
def exitCommands(self, ctx:AutolevParser.CommandsContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#vec.
|
||||
def enterVec(self, ctx:AutolevParser.VecContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#vec.
|
||||
def exitVec(self, ctx:AutolevParser.VecContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#parens.
|
||||
def enterParens(self, ctx:AutolevParser.ParensContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#parens.
|
||||
def exitParens(self, ctx:AutolevParser.ParensContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#VectorOrDyadic.
|
||||
def enterVectorOrDyadic(self, ctx:AutolevParser.VectorOrDyadicContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#VectorOrDyadic.
|
||||
def exitVectorOrDyadic(self, ctx:AutolevParser.VectorOrDyadicContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#Exponent.
|
||||
def enterExponent(self, ctx:AutolevParser.ExponentContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#Exponent.
|
||||
def exitExponent(self, ctx:AutolevParser.ExponentContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#MulDiv.
|
||||
def enterMulDiv(self, ctx:AutolevParser.MulDivContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#MulDiv.
|
||||
def exitMulDiv(self, ctx:AutolevParser.MulDivContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#AddSub.
|
||||
def enterAddSub(self, ctx:AutolevParser.AddSubContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#AddSub.
|
||||
def exitAddSub(self, ctx:AutolevParser.AddSubContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#float.
|
||||
def enterFloat(self, ctx:AutolevParser.FloatContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#float.
|
||||
def exitFloat(self, ctx:AutolevParser.FloatContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#int.
|
||||
def enterInt(self, ctx:AutolevParser.IntContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#int.
|
||||
def exitInt(self, ctx:AutolevParser.IntContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#idEqualsExpr.
|
||||
def enterIdEqualsExpr(self, ctx:AutolevParser.IdEqualsExprContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#idEqualsExpr.
|
||||
def exitIdEqualsExpr(self, ctx:AutolevParser.IdEqualsExprContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#negativeOne.
|
||||
def enterNegativeOne(self, ctx:AutolevParser.NegativeOneContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#negativeOne.
|
||||
def exitNegativeOne(self, ctx:AutolevParser.NegativeOneContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#function.
|
||||
def enterFunction(self, ctx:AutolevParser.FunctionContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#function.
|
||||
def exitFunction(self, ctx:AutolevParser.FunctionContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#rangess.
|
||||
def enterRangess(self, ctx:AutolevParser.RangessContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#rangess.
|
||||
def exitRangess(self, ctx:AutolevParser.RangessContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#colon.
|
||||
def enterColon(self, ctx:AutolevParser.ColonContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#colon.
|
||||
def exitColon(self, ctx:AutolevParser.ColonContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#id.
|
||||
def enterId(self, ctx:AutolevParser.IdContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#id.
|
||||
def exitId(self, ctx:AutolevParser.IdContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#exp.
|
||||
def enterExp(self, ctx:AutolevParser.ExpContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#exp.
|
||||
def exitExp(self, ctx:AutolevParser.ExpContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#matrices.
|
||||
def enterMatrices(self, ctx:AutolevParser.MatricesContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#matrices.
|
||||
def exitMatrices(self, ctx:AutolevParser.MatricesContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by AutolevParser#Indexing.
|
||||
def enterIndexing(self, ctx:AutolevParser.IndexingContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by AutolevParser#Indexing.
|
||||
def exitIndexing(self, ctx:AutolevParser.IndexingContext):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
del AutolevParser
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,86 @@
|
||||
import os
|
||||
import subprocess
|
||||
import glob
|
||||
|
||||
from sympy.utilities.misc import debug
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
grammar_file = os.path.abspath(os.path.join(here, "Autolev.g4"))
|
||||
dir_autolev_antlr = os.path.join(here, "_antlr")
|
||||
|
||||
header = '''\
|
||||
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
|
||||
#
|
||||
# Generated with antlr4
|
||||
# antlr4 is licensed under the BSD-3-Clause License
|
||||
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
|
||||
'''
|
||||
|
||||
|
||||
def check_antlr_version():
|
||||
debug("Checking antlr4 version...")
|
||||
|
||||
try:
|
||||
debug(subprocess.check_output(["antlr4"])
|
||||
.decode('utf-8').split("\n")[0])
|
||||
return True
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
debug("The 'antlr4' command line tool is not installed, "
|
||||
"or not on your PATH.\n"
|
||||
"> Please refer to the README.md file for more information.")
|
||||
return False
|
||||
|
||||
|
||||
def build_parser(output_dir=dir_autolev_antlr):
|
||||
check_antlr_version()
|
||||
|
||||
debug("Updating ANTLR-generated code in {}".format(output_dir))
|
||||
|
||||
if not os.path.exists(output_dir):
|
||||
os.makedirs(output_dir)
|
||||
|
||||
with open(os.path.join(output_dir, "__init__.py"), "w+") as fp:
|
||||
fp.write(header)
|
||||
|
||||
args = [
|
||||
"antlr4",
|
||||
grammar_file,
|
||||
"-o", output_dir,
|
||||
"-no-visitor",
|
||||
]
|
||||
|
||||
debug("Running code generation...\n\t$ {}".format(" ".join(args)))
|
||||
subprocess.check_output(args, cwd=output_dir)
|
||||
|
||||
debug("Applying headers, removing unnecessary files and renaming...")
|
||||
# Handle case insensitive file systems. If the files are already
|
||||
# generated, they will be written to autolev* but Autolev*.* won't match them.
|
||||
for path in (glob.glob(os.path.join(output_dir, "Autolev*.*")) or
|
||||
glob.glob(os.path.join(output_dir, "autolev*.*"))):
|
||||
|
||||
# Remove files ending in .interp or .tokens as they are not needed.
|
||||
if not path.endswith(".py"):
|
||||
os.unlink(path)
|
||||
continue
|
||||
|
||||
new_path = os.path.join(output_dir, os.path.basename(path).lower())
|
||||
with open(path, 'r') as f:
|
||||
lines = [line.rstrip().replace('AutolevParser import', 'autolevparser import') +'\n'
|
||||
for line in f]
|
||||
|
||||
os.unlink(path)
|
||||
|
||||
with open(new_path, "w") as out_file:
|
||||
offset = 0
|
||||
while lines[offset].startswith('#'):
|
||||
offset += 1
|
||||
out_file.write(header)
|
||||
out_file.writelines(lines[offset:])
|
||||
|
||||
debug("\t{}".format(new_path))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
build_parser()
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
from importlib.metadata import version
|
||||
from sympy.external import import_module
|
||||
|
||||
|
||||
autolevparser = import_module('sympy.parsing.autolev._antlr.autolevparser',
|
||||
import_kwargs={'fromlist': ['AutolevParser']})
|
||||
autolevlexer = import_module('sympy.parsing.autolev._antlr.autolevlexer',
|
||||
import_kwargs={'fromlist': ['AutolevLexer']})
|
||||
autolevlistener = import_module('sympy.parsing.autolev._antlr.autolevlistener',
|
||||
import_kwargs={'fromlist': ['AutolevListener']})
|
||||
|
||||
AutolevParser = getattr(autolevparser, 'AutolevParser', None)
|
||||
AutolevLexer = getattr(autolevlexer, 'AutolevLexer', None)
|
||||
AutolevListener = getattr(autolevlistener, 'AutolevListener', None)
|
||||
|
||||
|
||||
def parse_autolev(autolev_code, include_numeric):
|
||||
antlr4 = import_module('antlr4')
|
||||
if not antlr4 or not version('antlr4-python3-runtime').startswith('4.11'):
|
||||
raise ImportError("Autolev parsing requires the antlr4 Python package,"
|
||||
" provided by pip (antlr4-python3-runtime)"
|
||||
" conda (antlr-python-runtime), version 4.11")
|
||||
try:
|
||||
l = autolev_code.readlines()
|
||||
input_stream = antlr4.InputStream("".join(l))
|
||||
except Exception:
|
||||
input_stream = antlr4.InputStream(autolev_code)
|
||||
|
||||
if AutolevListener:
|
||||
from ._listener_autolev_antlr import MyListener
|
||||
lexer = AutolevLexer(input_stream)
|
||||
token_stream = antlr4.CommonTokenStream(lexer)
|
||||
parser = AutolevParser(token_stream)
|
||||
tree = parser.prog()
|
||||
my_listener = MyListener(include_numeric)
|
||||
walker = antlr4.ParseTreeWalker()
|
||||
walker.walk(my_listener, tree)
|
||||
return "".join(my_listener.output_code)
|
||||
@@ -0,0 +1,9 @@
|
||||
# parsing/tests/test_autolev.py uses the .al files in this directory as inputs and checks
|
||||
# the equivalence of the parser generated codes and the respective .py files.
|
||||
|
||||
# By default, this directory contains tests for all rules of the parser.
|
||||
|
||||
# Additional tests consisting of full physics examples shall be made available soon in
|
||||
# the form of another repository. One shall be able to copy the contents of that repo
|
||||
# to this folder and use those tests after uncommenting the respective code in
|
||||
# parsing/tests/test_autolev.py.
|
||||
@@ -0,0 +1,33 @@
|
||||
CONSTANTS G,LB,W,H
|
||||
MOTIONVARIABLES' THETA'',PHI'',OMEGA',ALPHA'
|
||||
NEWTONIAN N
|
||||
BODIES A,B
|
||||
SIMPROT(N,A,2,THETA)
|
||||
SIMPROT(A,B,3,PHI)
|
||||
POINT O
|
||||
LA = (LB-H/2)/2
|
||||
P_O_AO> = LA*A3>
|
||||
P_O_BO> = LB*A3>
|
||||
OMEGA = THETA'
|
||||
ALPHA = PHI'
|
||||
W_A_N> = OMEGA*N2>
|
||||
W_B_A> = ALPHA*A3>
|
||||
V_O_N> = 0>
|
||||
V2PTS(N, A, O, AO)
|
||||
V2PTS(N, A, O, BO)
|
||||
MASS A=MA, B=MB
|
||||
IAXX = 1/12*MA*(2*LA)^2
|
||||
IAYY = IAXX
|
||||
IAZZ = 0
|
||||
IBXX = 1/12*MB*H^2
|
||||
IBYY = 1/12*MB*(W^2+H^2)
|
||||
IBZZ = 1/12*MB*W^2
|
||||
INERTIA A, IAXX, IAYY, IAZZ
|
||||
INERTIA B, IBXX, IBYY, IBZZ
|
||||
GRAVITY(G*N3>)
|
||||
ZERO = FR() + FRSTAR()
|
||||
KANE()
|
||||
INPUT LB=0.2,H=0.1,W=0.2,MA=0.01,MB=0.1,G=9.81
|
||||
INPUT THETA = 90 DEG, PHI = 0.5 DEG, OMEGA=0, ALPHA=0
|
||||
INPUT TFINAL=10, INTEGSTP=0.02
|
||||
CODE DYNAMICS() some_filename.c
|
||||
@@ -0,0 +1,55 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
g, lb, w, h = _sm.symbols('g lb w h', real=True)
|
||||
theta, phi, omega, alpha = _me.dynamicsymbols('theta phi omega alpha')
|
||||
theta_d, phi_d, omega_d, alpha_d = _me.dynamicsymbols('theta_ phi_ omega_ alpha_', 1)
|
||||
theta_dd, phi_dd = _me.dynamicsymbols('theta_ phi_', 2)
|
||||
frame_n = _me.ReferenceFrame('n')
|
||||
body_a_cm = _me.Point('a_cm')
|
||||
body_a_cm.set_vel(frame_n, 0)
|
||||
body_a_f = _me.ReferenceFrame('a_f')
|
||||
body_a = _me.RigidBody('a', body_a_cm, body_a_f, _sm.symbols('m'), (_me.outer(body_a_f.x,body_a_f.x),body_a_cm))
|
||||
body_b_cm = _me.Point('b_cm')
|
||||
body_b_cm.set_vel(frame_n, 0)
|
||||
body_b_f = _me.ReferenceFrame('b_f')
|
||||
body_b = _me.RigidBody('b', body_b_cm, body_b_f, _sm.symbols('m'), (_me.outer(body_b_f.x,body_b_f.x),body_b_cm))
|
||||
body_a_f.orient(frame_n, 'Axis', [theta, frame_n.y])
|
||||
body_b_f.orient(body_a_f, 'Axis', [phi, body_a_f.z])
|
||||
point_o = _me.Point('o')
|
||||
la = (lb-h/2)/2
|
||||
body_a_cm.set_pos(point_o, la*body_a_f.z)
|
||||
body_b_cm.set_pos(point_o, lb*body_a_f.z)
|
||||
body_a_f.set_ang_vel(frame_n, omega*frame_n.y)
|
||||
body_b_f.set_ang_vel(body_a_f, alpha*body_a_f.z)
|
||||
point_o.set_vel(frame_n, 0)
|
||||
body_a_cm.v2pt_theory(point_o,frame_n,body_a_f)
|
||||
body_b_cm.v2pt_theory(point_o,frame_n,body_a_f)
|
||||
ma = _sm.symbols('ma')
|
||||
body_a.mass = ma
|
||||
mb = _sm.symbols('mb')
|
||||
body_b.mass = mb
|
||||
iaxx = 1/12*ma*(2*la)**2
|
||||
iayy = iaxx
|
||||
iazz = 0
|
||||
ibxx = 1/12*mb*h**2
|
||||
ibyy = 1/12*mb*(w**2+h**2)
|
||||
ibzz = 1/12*mb*w**2
|
||||
body_a.inertia = (_me.inertia(body_a_f, iaxx, iayy, iazz, 0, 0, 0), body_a_cm)
|
||||
body_b.inertia = (_me.inertia(body_b_f, ibxx, ibyy, ibzz, 0, 0, 0), body_b_cm)
|
||||
force_a = body_a.mass*(g*frame_n.z)
|
||||
force_b = body_b.mass*(g*frame_n.z)
|
||||
kd_eqs = [theta_d - omega, phi_d - alpha]
|
||||
forceList = [(body_a.masscenter,body_a.mass*(g*frame_n.z)), (body_b.masscenter,body_b.mass*(g*frame_n.z))]
|
||||
kane = _me.KanesMethod(frame_n, q_ind=[theta,phi], u_ind=[omega, alpha], kd_eqs = kd_eqs)
|
||||
fr, frstar = kane.kanes_equations([body_a, body_b], forceList)
|
||||
zero = fr+frstar
|
||||
from pydy.system import System
|
||||
sys = System(kane, constants = {g:9.81, lb:0.2, w:0.2, h:0.1, ma:0.01, mb:0.1},
|
||||
specifieds={},
|
||||
initial_conditions={theta:_np.deg2rad(90), phi:_np.deg2rad(0.5), omega:0, alpha:0},
|
||||
times = _np.linspace(0.0, 10, 10/0.02))
|
||||
|
||||
y=sys.integrate()
|
||||
@@ -0,0 +1,25 @@
|
||||
MOTIONVARIABLES' Q{2}', U{2}'
|
||||
CONSTANTS L,M,G
|
||||
NEWTONIAN N
|
||||
FRAMES A,B
|
||||
SIMPROT(N, A, 3, Q1)
|
||||
SIMPROT(N, B, 3, Q2)
|
||||
W_A_N>=U1*N3>
|
||||
W_B_N>=U2*N3>
|
||||
POINT O
|
||||
PARTICLES P,R
|
||||
P_O_P> = L*A1>
|
||||
P_P_R> = L*B1>
|
||||
V_O_N> = 0>
|
||||
V2PTS(N, A, O, P)
|
||||
V2PTS(N, B, P, R)
|
||||
MASS P=M, R=M
|
||||
Q1' = U1
|
||||
Q2' = U2
|
||||
GRAVITY(G*N1>)
|
||||
ZERO = FR() + FRSTAR()
|
||||
KANE()
|
||||
INPUT M=1,G=9.81,L=1
|
||||
INPUT Q1=.1,Q2=.2,U1=0,U2=0
|
||||
INPUT TFINAL=10, INTEGSTP=.01
|
||||
CODE DYNAMICS() some_filename.c
|
||||
@@ -0,0 +1,39 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
q1, q2, u1, u2 = _me.dynamicsymbols('q1 q2 u1 u2')
|
||||
q1_d, q2_d, u1_d, u2_d = _me.dynamicsymbols('q1_ q2_ u1_ u2_', 1)
|
||||
l, m, g = _sm.symbols('l m g', real=True)
|
||||
frame_n = _me.ReferenceFrame('n')
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
frame_b = _me.ReferenceFrame('b')
|
||||
frame_a.orient(frame_n, 'Axis', [q1, frame_n.z])
|
||||
frame_b.orient(frame_n, 'Axis', [q2, frame_n.z])
|
||||
frame_a.set_ang_vel(frame_n, u1*frame_n.z)
|
||||
frame_b.set_ang_vel(frame_n, u2*frame_n.z)
|
||||
point_o = _me.Point('o')
|
||||
particle_p = _me.Particle('p', _me.Point('p_pt'), _sm.Symbol('m'))
|
||||
particle_r = _me.Particle('r', _me.Point('r_pt'), _sm.Symbol('m'))
|
||||
particle_p.point.set_pos(point_o, l*frame_a.x)
|
||||
particle_r.point.set_pos(particle_p.point, l*frame_b.x)
|
||||
point_o.set_vel(frame_n, 0)
|
||||
particle_p.point.v2pt_theory(point_o,frame_n,frame_a)
|
||||
particle_r.point.v2pt_theory(particle_p.point,frame_n,frame_b)
|
||||
particle_p.mass = m
|
||||
particle_r.mass = m
|
||||
force_p = particle_p.mass*(g*frame_n.x)
|
||||
force_r = particle_r.mass*(g*frame_n.x)
|
||||
kd_eqs = [q1_d - u1, q2_d - u2]
|
||||
forceList = [(particle_p.point,particle_p.mass*(g*frame_n.x)), (particle_r.point,particle_r.mass*(g*frame_n.x))]
|
||||
kane = _me.KanesMethod(frame_n, q_ind=[q1,q2], u_ind=[u1, u2], kd_eqs = kd_eqs)
|
||||
fr, frstar = kane.kanes_equations([particle_p, particle_r], forceList)
|
||||
zero = fr+frstar
|
||||
from pydy.system import System
|
||||
sys = System(kane, constants = {l:1, m:1, g:9.81},
|
||||
specifieds={},
|
||||
initial_conditions={q1:.1, q2:.2, u1:0, u2:0},
|
||||
times = _np.linspace(0.0, 10, 10/.01))
|
||||
|
||||
y=sys.integrate()
|
||||
@@ -0,0 +1,19 @@
|
||||
CONSTANTS M,K,B,G
|
||||
MOTIONVARIABLES' POSITION',SPEED'
|
||||
VARIABLES O
|
||||
FORCE = O*SIN(T)
|
||||
NEWTONIAN CEILING
|
||||
POINTS ORIGIN
|
||||
V_ORIGIN_CEILING> = 0>
|
||||
PARTICLES BLOCK
|
||||
P_ORIGIN_BLOCK> = POSITION*CEILING1>
|
||||
MASS BLOCK=M
|
||||
V_BLOCK_CEILING>=SPEED*CEILING1>
|
||||
POSITION' = SPEED
|
||||
FORCE_MAGNITUDE = M*G-K*POSITION-B*SPEED+FORCE
|
||||
FORCE_BLOCK>=EXPLICIT(FORCE_MAGNITUDE*CEILING1>)
|
||||
ZERO = FR() + FRSTAR()
|
||||
KANE()
|
||||
INPUT TFINAL=10.0, INTEGSTP=0.01
|
||||
INPUT M=1.0, K=1.0, B=0.2, G=9.8, POSITION=0.1, SPEED=-1.0, O=2
|
||||
CODE DYNAMICS() dummy_file.c
|
||||
@@ -0,0 +1,31 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
m, k, b, g = _sm.symbols('m k b g', real=True)
|
||||
position, speed = _me.dynamicsymbols('position speed')
|
||||
position_d, speed_d = _me.dynamicsymbols('position_ speed_', 1)
|
||||
o = _me.dynamicsymbols('o')
|
||||
force = o*_sm.sin(_me.dynamicsymbols._t)
|
||||
frame_ceiling = _me.ReferenceFrame('ceiling')
|
||||
point_origin = _me.Point('origin')
|
||||
point_origin.set_vel(frame_ceiling, 0)
|
||||
particle_block = _me.Particle('block', _me.Point('block_pt'), _sm.Symbol('m'))
|
||||
particle_block.point.set_pos(point_origin, position*frame_ceiling.x)
|
||||
particle_block.mass = m
|
||||
particle_block.point.set_vel(frame_ceiling, speed*frame_ceiling.x)
|
||||
force_magnitude = m*g-k*position-b*speed+force
|
||||
force_block = (force_magnitude*frame_ceiling.x).subs({position_d:speed})
|
||||
kd_eqs = [position_d - speed]
|
||||
forceList = [(particle_block.point,(force_magnitude*frame_ceiling.x).subs({position_d:speed}))]
|
||||
kane = _me.KanesMethod(frame_ceiling, q_ind=[position], u_ind=[speed], kd_eqs = kd_eqs)
|
||||
fr, frstar = kane.kanes_equations([particle_block], forceList)
|
||||
zero = fr+frstar
|
||||
from pydy.system import System
|
||||
sys = System(kane, constants = {m:1.0, k:1.0, b:0.2, g:9.8},
|
||||
specifieds={_me.dynamicsymbols('t'):lambda x, t: t, o:2},
|
||||
initial_conditions={position:0.1, speed:-1*1.0},
|
||||
times = _np.linspace(0.0, 10.0, 10.0/0.01))
|
||||
|
||||
y=sys.integrate()
|
||||
@@ -0,0 +1,20 @@
|
||||
MOTIONVARIABLES' Q{2}''
|
||||
CONSTANTS L,M,G
|
||||
NEWTONIAN N
|
||||
POINT PN
|
||||
V_PN_N> = 0>
|
||||
THETA1 = ATAN(Q2/Q1)
|
||||
FRAMES A
|
||||
SIMPROT(N, A, 3, THETA1)
|
||||
PARTICLES P
|
||||
P_PN_P> = Q1*N1>+Q2*N2>
|
||||
MASS P=M
|
||||
V_P_N>=DT(P_P_PN>, N)
|
||||
F_V = DOT(EXPRESS(V_P_N>,A), A1>)
|
||||
GRAVITY(G*N1>)
|
||||
DEPENDENT[1] = F_V
|
||||
CONSTRAIN(DEPENDENT[Q1'])
|
||||
ZERO=FR()+FRSTAR()
|
||||
F_C = MAG(P_P_PN>)-L
|
||||
CONFIG[1]=F_C
|
||||
ZERO[2]=CONFIG[1]
|
||||
@@ -0,0 +1,36 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
q1, q2 = _me.dynamicsymbols('q1 q2')
|
||||
q1_d, q2_d = _me.dynamicsymbols('q1_ q2_', 1)
|
||||
q1_dd, q2_dd = _me.dynamicsymbols('q1_ q2_', 2)
|
||||
l, m, g = _sm.symbols('l m g', real=True)
|
||||
frame_n = _me.ReferenceFrame('n')
|
||||
point_pn = _me.Point('pn')
|
||||
point_pn.set_vel(frame_n, 0)
|
||||
theta1 = _sm.atan(q2/q1)
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
frame_a.orient(frame_n, 'Axis', [theta1, frame_n.z])
|
||||
particle_p = _me.Particle('p', _me.Point('p_pt'), _sm.Symbol('m'))
|
||||
particle_p.point.set_pos(point_pn, q1*frame_n.x+q2*frame_n.y)
|
||||
particle_p.mass = m
|
||||
particle_p.point.set_vel(frame_n, (point_pn.pos_from(particle_p.point)).dt(frame_n))
|
||||
f_v = _me.dot((particle_p.point.vel(frame_n)).express(frame_a), frame_a.x)
|
||||
force_p = particle_p.mass*(g*frame_n.x)
|
||||
dependent = _sm.Matrix([[0]])
|
||||
dependent[0] = f_v
|
||||
velocity_constraints = [i for i in dependent]
|
||||
u_q1_d = _me.dynamicsymbols('u_q1_d')
|
||||
u_q2_d = _me.dynamicsymbols('u_q2_d')
|
||||
kd_eqs = [q1_d-u_q1_d, q2_d-u_q2_d]
|
||||
forceList = [(particle_p.point,particle_p.mass*(g*frame_n.x))]
|
||||
kane = _me.KanesMethod(frame_n, q_ind=[q1,q2], u_ind=[u_q2_d], u_dependent=[u_q1_d], kd_eqs = kd_eqs, velocity_constraints = velocity_constraints)
|
||||
fr, frstar = kane.kanes_equations([particle_p], forceList)
|
||||
zero = fr+frstar
|
||||
f_c = point_pn.pos_from(particle_p.point).magnitude()-l
|
||||
config = _sm.Matrix([[0]])
|
||||
config[0] = f_c
|
||||
zero = zero.row_insert(zero.shape[0], _sm.Matrix([[0]]))
|
||||
zero[zero.shape[0]-1] = config[0]
|
||||
@@ -0,0 +1,8 @@
|
||||
% ruletest1.al
|
||||
CONSTANTS F = 3, G = 9.81
|
||||
CONSTANTS A, B
|
||||
CONSTANTS S, S1, S2+, S3+, S4-
|
||||
CONSTANTS K{4}, L{1:3}, P{1:2,1:3}
|
||||
CONSTANTS C{2,3}
|
||||
E1 = A*F + S2 - G
|
||||
E2 = F^2 + K3*K2*G
|
||||
@@ -0,0 +1,15 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
f = _sm.S(3)
|
||||
g = _sm.S(9.81)
|
||||
a, b = _sm.symbols('a b', real=True)
|
||||
s, s1 = _sm.symbols('s s1', real=True)
|
||||
s2, s3 = _sm.symbols('s2 s3', real=True, nonnegative=True)
|
||||
s4 = _sm.symbols('s4', real=True, nonpositive=True)
|
||||
k1, k2, k3, k4, l1, l2, l3, p11, p12, p13, p21, p22, p23 = _sm.symbols('k1 k2 k3 k4 l1 l2 l3 p11 p12 p13 p21 p22 p23', real=True)
|
||||
c11, c12, c13, c21, c22, c23 = _sm.symbols('c11 c12 c13 c21 c22 c23', real=True)
|
||||
e1 = a*f+s2-g
|
||||
e2 = f**2+k3*k2*g
|
||||
@@ -0,0 +1,58 @@
|
||||
% ruletest10.al
|
||||
|
||||
VARIABLES X,Y
|
||||
COMPLEX ON
|
||||
CONSTANTS A,B
|
||||
E = A*(B*X+Y)^2
|
||||
M = [E;E]
|
||||
EXPAND(E)
|
||||
EXPAND(M)
|
||||
FACTOR(E,X)
|
||||
FACTOR(M,X)
|
||||
|
||||
EQN[1] = A*X + B*Y
|
||||
EQN[2] = 2*A*X - 3*B*Y
|
||||
SOLVE(EQN, X, Y)
|
||||
RHS_Y = RHS(Y)
|
||||
E = (X+Y)^2 + 2*X^2
|
||||
ARRANGE(E, 2, X)
|
||||
|
||||
CONSTANTS A,B,C
|
||||
M = [A,B;C,0]
|
||||
M2 = EVALUATE(M,A=1,B=2,C=3)
|
||||
EIG(M2, EIGVALUE, EIGVEC)
|
||||
|
||||
NEWTONIAN N
|
||||
FRAMES A
|
||||
SIMPROT(N, A, N1>, X)
|
||||
DEGREES OFF
|
||||
SIMPROT(N, A, N1>, PI/2)
|
||||
|
||||
CONSTANTS C{3}
|
||||
V> = C1*A1> + C2*A2> + C3*A3>
|
||||
POINTS O, P
|
||||
P_P_O> = C1*A1>
|
||||
EXPRESS(V>,N)
|
||||
EXPRESS(P_P_O>,N)
|
||||
W_A_N> = C3*A3>
|
||||
ANGVEL(A,N)
|
||||
|
||||
V2PTS(N,A,O,P)
|
||||
PARTICLES P{2}
|
||||
V2PTS(N,A,P1,P2)
|
||||
A2PTS(N,A,P1,P)
|
||||
|
||||
BODIES B{2}
|
||||
CONSTANT G
|
||||
GRAVITY(G*N1>)
|
||||
|
||||
VARIABLE Z
|
||||
V> = X*A1> + Y*A3>
|
||||
P_P_O> = X*A1> + Y*A2>
|
||||
X = 2*Z
|
||||
Y = Z
|
||||
EXPLICIT(V>)
|
||||
EXPLICIT(P_P_O>)
|
||||
|
||||
FORCE(O/P1, X*Y*A1>)
|
||||
FORCE(P2, X*Y*A1>)
|
||||
@@ -0,0 +1,64 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
x, y = _me.dynamicsymbols('x y')
|
||||
a, b = _sm.symbols('a b', real=True)
|
||||
e = a*(b*x+y)**2
|
||||
m = _sm.Matrix([e,e]).reshape(2, 1)
|
||||
e = e.expand()
|
||||
m = _sm.Matrix([i.expand() for i in m]).reshape((m).shape[0], (m).shape[1])
|
||||
e = _sm.factor(e, x)
|
||||
m = _sm.Matrix([_sm.factor(i,x) for i in m]).reshape((m).shape[0], (m).shape[1])
|
||||
eqn = _sm.Matrix([[0]])
|
||||
eqn[0] = a*x+b*y
|
||||
eqn = eqn.row_insert(eqn.shape[0], _sm.Matrix([[0]]))
|
||||
eqn[eqn.shape[0]-1] = 2*a*x-3*b*y
|
||||
print(_sm.solve(eqn,x,y))
|
||||
rhs_y = _sm.solve(eqn,x,y)[y]
|
||||
e = (x+y)**2+2*x**2
|
||||
e.collect(x)
|
||||
a, b, c = _sm.symbols('a b c', real=True)
|
||||
m = _sm.Matrix([a,b,c,0]).reshape(2, 2)
|
||||
m2 = _sm.Matrix([i.subs({a:1,b:2,c:3}) for i in m]).reshape((m).shape[0], (m).shape[1])
|
||||
eigvalue = _sm.Matrix([i.evalf() for i in (m2).eigenvals().keys()])
|
||||
eigvec = _sm.Matrix([i[2][0].evalf() for i in (m2).eigenvects()]).reshape(m2.shape[0], m2.shape[1])
|
||||
frame_n = _me.ReferenceFrame('n')
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
frame_a.orient(frame_n, 'Axis', [x, frame_n.x])
|
||||
frame_a.orient(frame_n, 'Axis', [_sm.pi/2, frame_n.x])
|
||||
c1, c2, c3 = _sm.symbols('c1 c2 c3', real=True)
|
||||
v = c1*frame_a.x+c2*frame_a.y+c3*frame_a.z
|
||||
point_o = _me.Point('o')
|
||||
point_p = _me.Point('p')
|
||||
point_o.set_pos(point_p, c1*frame_a.x)
|
||||
v = (v).express(frame_n)
|
||||
point_o.set_pos(point_p, (point_o.pos_from(point_p)).express(frame_n))
|
||||
frame_a.set_ang_vel(frame_n, c3*frame_a.z)
|
||||
print(frame_n.ang_vel_in(frame_a))
|
||||
point_p.v2pt_theory(point_o,frame_n,frame_a)
|
||||
particle_p1 = _me.Particle('p1', _me.Point('p1_pt'), _sm.Symbol('m'))
|
||||
particle_p2 = _me.Particle('p2', _me.Point('p2_pt'), _sm.Symbol('m'))
|
||||
particle_p2.point.v2pt_theory(particle_p1.point,frame_n,frame_a)
|
||||
point_p.a2pt_theory(particle_p1.point,frame_n,frame_a)
|
||||
body_b1_cm = _me.Point('b1_cm')
|
||||
body_b1_cm.set_vel(frame_n, 0)
|
||||
body_b1_f = _me.ReferenceFrame('b1_f')
|
||||
body_b1 = _me.RigidBody('b1', body_b1_cm, body_b1_f, _sm.symbols('m'), (_me.outer(body_b1_f.x,body_b1_f.x),body_b1_cm))
|
||||
body_b2_cm = _me.Point('b2_cm')
|
||||
body_b2_cm.set_vel(frame_n, 0)
|
||||
body_b2_f = _me.ReferenceFrame('b2_f')
|
||||
body_b2 = _me.RigidBody('b2', body_b2_cm, body_b2_f, _sm.symbols('m'), (_me.outer(body_b2_f.x,body_b2_f.x),body_b2_cm))
|
||||
g = _sm.symbols('g', real=True)
|
||||
force_p1 = particle_p1.mass*(g*frame_n.x)
|
||||
force_p2 = particle_p2.mass*(g*frame_n.x)
|
||||
force_b1 = body_b1.mass*(g*frame_n.x)
|
||||
force_b2 = body_b2.mass*(g*frame_n.x)
|
||||
z = _me.dynamicsymbols('z')
|
||||
v = x*frame_a.x+y*frame_a.z
|
||||
point_o.set_pos(point_p, x*frame_a.x+y*frame_a.y)
|
||||
v = (v).subs({x:2*z, y:z})
|
||||
point_o.set_pos(point_p, (point_o.pos_from(point_p)).subs({x:2*z, y:z}))
|
||||
force_o = -1*(x*y*frame_a.x)
|
||||
force_p1 = particle_p1.mass*(g*frame_n.x)+ x*y*frame_a.x
|
||||
@@ -0,0 +1,6 @@
|
||||
VARIABLES X, Y
|
||||
CONSTANTS A{1:2, 1:2}, B{1:2}
|
||||
EQN[1] = A11*x + A12*y - B1
|
||||
EQN[2] = A21*x + A22*y - B2
|
||||
INPUT A11=2, A12=5, A21=3, A22=4, B1=7, B2=6
|
||||
CODE ALGEBRAIC(EQN, X, Y) some_filename.c
|
||||
@@ -0,0 +1,14 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
x, y = _me.dynamicsymbols('x y')
|
||||
a11, a12, a21, a22, b1, b2 = _sm.symbols('a11 a12 a21 a22 b1 b2', real=True)
|
||||
eqn = _sm.Matrix([[0]])
|
||||
eqn[0] = a11*x+a12*y-b1
|
||||
eqn = eqn.row_insert(eqn.shape[0], _sm.Matrix([[0]]))
|
||||
eqn[eqn.shape[0]-1] = a21*x+a22*y-b2
|
||||
eqn_list = []
|
||||
for i in eqn: eqn_list.append(i.subs({a11:2, a12:5, a21:3, a22:4, b1:7, b2:6}))
|
||||
print(_sm.linsolve(eqn_list, x,y))
|
||||
@@ -0,0 +1,7 @@
|
||||
VARIABLES X,Y
|
||||
CONSTANTS A,B,R
|
||||
EQN[1] = A*X^3+B*Y^2-R
|
||||
EQN[2] = A*SIN(X)^2 + B*COS(2*Y) - R^2
|
||||
INPUT A=2.0, B=3.0, R=1.0
|
||||
INPUT X = 30 DEG, Y = 3.14
|
||||
CODE NONLINEAR(EQN,X,Y) some_filename.c
|
||||
@@ -0,0 +1,14 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
x, y = _me.dynamicsymbols('x y')
|
||||
a, b, r = _sm.symbols('a b r', real=True)
|
||||
eqn = _sm.Matrix([[0]])
|
||||
eqn[0] = a*x**3+b*y**2-r
|
||||
eqn = eqn.row_insert(eqn.shape[0], _sm.Matrix([[0]]))
|
||||
eqn[eqn.shape[0]-1] = a*_sm.sin(x)**2+b*_sm.cos(2*y)-r**2
|
||||
matrix_list = []
|
||||
for i in eqn:matrix_list.append(i.subs({a:2.0, b:3.0, r:1.0}))
|
||||
print(_sm.nsolve(matrix_list,(x,y),(_np.deg2rad(30),3.14)))
|
||||
@@ -0,0 +1,12 @@
|
||||
% ruletest2.al
|
||||
VARIABLES X1,X2
|
||||
SPECIFIED F1 = X1*X2 + 3*X1^2
|
||||
SPECIFIED F2=X1*T+X2*T^2
|
||||
VARIABLE X', Y''
|
||||
MOTIONVARIABLES Q{3}, U{2}
|
||||
VARIABLES P{2}'
|
||||
VARIABLE W{3}', R{2}''
|
||||
VARIABLES C{1:2, 1:2}
|
||||
VARIABLES D{1,3}
|
||||
VARIABLES J{1:2}
|
||||
IMAGINARY N
|
||||
@@ -0,0 +1,22 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
x1, x2 = _me.dynamicsymbols('x1 x2')
|
||||
f1 = x1*x2+3*x1**2
|
||||
f2 = x1*_me.dynamicsymbols._t+x2*_me.dynamicsymbols._t**2
|
||||
x, y = _me.dynamicsymbols('x y')
|
||||
x_d, y_d = _me.dynamicsymbols('x_ y_', 1)
|
||||
y_dd = _me.dynamicsymbols('y_', 2)
|
||||
q1, q2, q3, u1, u2 = _me.dynamicsymbols('q1 q2 q3 u1 u2')
|
||||
p1, p2 = _me.dynamicsymbols('p1 p2')
|
||||
p1_d, p2_d = _me.dynamicsymbols('p1_ p2_', 1)
|
||||
w1, w2, w3, r1, r2 = _me.dynamicsymbols('w1 w2 w3 r1 r2')
|
||||
w1_d, w2_d, w3_d, r1_d, r2_d = _me.dynamicsymbols('w1_ w2_ w3_ r1_ r2_', 1)
|
||||
r1_dd, r2_dd = _me.dynamicsymbols('r1_ r2_', 2)
|
||||
c11, c12, c21, c22 = _me.dynamicsymbols('c11 c12 c21 c22')
|
||||
d11, d12, d13 = _me.dynamicsymbols('d11 d12 d13')
|
||||
j1, j2 = _me.dynamicsymbols('j1 j2')
|
||||
n = _sm.symbols('n')
|
||||
n = _sm.I
|
||||
@@ -0,0 +1,25 @@
|
||||
% ruletest3.al
|
||||
FRAMES A, B
|
||||
NEWTONIAN N
|
||||
|
||||
VARIABLES X{3}
|
||||
CONSTANTS L
|
||||
|
||||
V1> = X1*A1> + X2*A2> + X3*A3>
|
||||
V2> = X1*B1> + X2*B2> + X3*B3>
|
||||
V3> = X1*N1> + X2*N2> + X3*N3>
|
||||
|
||||
V> = V1> + V2> + V3>
|
||||
|
||||
POINTS C, D
|
||||
POINTS PO{3}
|
||||
|
||||
PARTICLES L
|
||||
PARTICLES P{3}
|
||||
|
||||
BODIES S
|
||||
BODIES R{2}
|
||||
|
||||
V4> = X1*S1> + X2*S2> + X3*S3>
|
||||
|
||||
P_C_SO> = L*N1>
|
||||
@@ -0,0 +1,37 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
frame_b = _me.ReferenceFrame('b')
|
||||
frame_n = _me.ReferenceFrame('n')
|
||||
x1, x2, x3 = _me.dynamicsymbols('x1 x2 x3')
|
||||
l = _sm.symbols('l', real=True)
|
||||
v1 = x1*frame_a.x+x2*frame_a.y+x3*frame_a.z
|
||||
v2 = x1*frame_b.x+x2*frame_b.y+x3*frame_b.z
|
||||
v3 = x1*frame_n.x+x2*frame_n.y+x3*frame_n.z
|
||||
v = v1+v2+v3
|
||||
point_c = _me.Point('c')
|
||||
point_d = _me.Point('d')
|
||||
point_po1 = _me.Point('po1')
|
||||
point_po2 = _me.Point('po2')
|
||||
point_po3 = _me.Point('po3')
|
||||
particle_l = _me.Particle('l', _me.Point('l_pt'), _sm.Symbol('m'))
|
||||
particle_p1 = _me.Particle('p1', _me.Point('p1_pt'), _sm.Symbol('m'))
|
||||
particle_p2 = _me.Particle('p2', _me.Point('p2_pt'), _sm.Symbol('m'))
|
||||
particle_p3 = _me.Particle('p3', _me.Point('p3_pt'), _sm.Symbol('m'))
|
||||
body_s_cm = _me.Point('s_cm')
|
||||
body_s_cm.set_vel(frame_n, 0)
|
||||
body_s_f = _me.ReferenceFrame('s_f')
|
||||
body_s = _me.RigidBody('s', body_s_cm, body_s_f, _sm.symbols('m'), (_me.outer(body_s_f.x,body_s_f.x),body_s_cm))
|
||||
body_r1_cm = _me.Point('r1_cm')
|
||||
body_r1_cm.set_vel(frame_n, 0)
|
||||
body_r1_f = _me.ReferenceFrame('r1_f')
|
||||
body_r1 = _me.RigidBody('r1', body_r1_cm, body_r1_f, _sm.symbols('m'), (_me.outer(body_r1_f.x,body_r1_f.x),body_r1_cm))
|
||||
body_r2_cm = _me.Point('r2_cm')
|
||||
body_r2_cm.set_vel(frame_n, 0)
|
||||
body_r2_f = _me.ReferenceFrame('r2_f')
|
||||
body_r2 = _me.RigidBody('r2', body_r2_cm, body_r2_f, _sm.symbols('m'), (_me.outer(body_r2_f.x,body_r2_f.x),body_r2_cm))
|
||||
v4 = x1*body_s_f.x+x2*body_s_f.y+x3*body_s_f.z
|
||||
body_s_cm.set_pos(point_c, l*frame_n.x)
|
||||
@@ -0,0 +1,20 @@
|
||||
% ruletest4.al
|
||||
|
||||
FRAMES A, B
|
||||
MOTIONVARIABLES Q{3}
|
||||
SIMPROT(A, B, 1, Q3)
|
||||
DCM = A_B
|
||||
M = DCM*3 - A_B
|
||||
|
||||
VARIABLES R
|
||||
CIRCLE_AREA = PI*R^2
|
||||
|
||||
VARIABLES U, A
|
||||
VARIABLES X, Y
|
||||
S = U*T - 1/2*A*T^2
|
||||
|
||||
EXPR1 = 2*A*0.5 - 1.25 + 0.25
|
||||
EXPR2 = -X^2 + Y^2 + 0.25*(X+Y)^2
|
||||
EXPR3 = 0.5E-10
|
||||
|
||||
DYADIC>> = A1>*A1> + A2>*A2> + A3>*A3>
|
||||
@@ -0,0 +1,20 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
frame_b = _me.ReferenceFrame('b')
|
||||
q1, q2, q3 = _me.dynamicsymbols('q1 q2 q3')
|
||||
frame_b.orient(frame_a, 'Axis', [q3, frame_a.x])
|
||||
dcm = frame_a.dcm(frame_b)
|
||||
m = dcm*3-frame_a.dcm(frame_b)
|
||||
r = _me.dynamicsymbols('r')
|
||||
circle_area = _sm.pi*r**2
|
||||
u, a = _me.dynamicsymbols('u a')
|
||||
x, y = _me.dynamicsymbols('x y')
|
||||
s = u*_me.dynamicsymbols._t-1/2*a*_me.dynamicsymbols._t**2
|
||||
expr1 = 2*a*0.5-1.25+0.25
|
||||
expr2 = -1*x**2+y**2+0.25*(x+y)**2
|
||||
expr3 = 0.5*10**(-10)
|
||||
dyadic = _me.outer(frame_a.x, frame_a.x)+_me.outer(frame_a.y, frame_a.y)+_me.outer(frame_a.z, frame_a.z)
|
||||
@@ -0,0 +1,32 @@
|
||||
% ruletest5.al
|
||||
VARIABLES X', Y'
|
||||
|
||||
E1 = (X+Y)^2 + (X-Y)^3
|
||||
E2 = (X-Y)^2
|
||||
E3 = X^2 + Y^2 + 2*X*Y
|
||||
|
||||
M1 = [E1;E2]
|
||||
M2 = [(X+Y)^2,(X-Y)^2]
|
||||
M3 = M1 + [X;Y]
|
||||
|
||||
AM = EXPAND(M1)
|
||||
CM = EXPAND([(X+Y)^2,(X-Y)^2])
|
||||
EM = EXPAND(M1 + [X;Y])
|
||||
F = EXPAND(E1)
|
||||
G = EXPAND(E2)
|
||||
|
||||
A = FACTOR(E3, X)
|
||||
BM = FACTOR(M1, X)
|
||||
CM = FACTOR(M1 + [X;Y], X)
|
||||
|
||||
A = D(E3, X)
|
||||
B = D(E3, Y)
|
||||
CM = D(M2, X)
|
||||
DM = D(M1 + [X;Y], X)
|
||||
FRAMES A, B
|
||||
A_B = [1,0,0;1,0,0;1,0,0]
|
||||
V1> = X*A1> + Y*A2> + X*Y*A3>
|
||||
E> = D(V1>, X, B)
|
||||
FM = DT(M1)
|
||||
GM = DT([(X+Y)^2,(X-Y)^2])
|
||||
H> = DT(V1>, B)
|
||||
@@ -0,0 +1,33 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
x, y = _me.dynamicsymbols('x y')
|
||||
x_d, y_d = _me.dynamicsymbols('x_ y_', 1)
|
||||
e1 = (x+y)**2+(x-y)**3
|
||||
e2 = (x-y)**2
|
||||
e3 = x**2+y**2+2*x*y
|
||||
m1 = _sm.Matrix([e1,e2]).reshape(2, 1)
|
||||
m2 = _sm.Matrix([(x+y)**2,(x-y)**2]).reshape(1, 2)
|
||||
m3 = m1+_sm.Matrix([x,y]).reshape(2, 1)
|
||||
am = _sm.Matrix([i.expand() for i in m1]).reshape((m1).shape[0], (m1).shape[1])
|
||||
cm = _sm.Matrix([i.expand() for i in _sm.Matrix([(x+y)**2,(x-y)**2]).reshape(1, 2)]).reshape((_sm.Matrix([(x+y)**2,(x-y)**2]).reshape(1, 2)).shape[0], (_sm.Matrix([(x+y)**2,(x-y)**2]).reshape(1, 2)).shape[1])
|
||||
em = _sm.Matrix([i.expand() for i in m1+_sm.Matrix([x,y]).reshape(2, 1)]).reshape((m1+_sm.Matrix([x,y]).reshape(2, 1)).shape[0], (m1+_sm.Matrix([x,y]).reshape(2, 1)).shape[1])
|
||||
f = (e1).expand()
|
||||
g = (e2).expand()
|
||||
a = _sm.factor((e3), x)
|
||||
bm = _sm.Matrix([_sm.factor(i, x) for i in m1]).reshape((m1).shape[0], (m1).shape[1])
|
||||
cm = _sm.Matrix([_sm.factor(i, x) for i in m1+_sm.Matrix([x,y]).reshape(2, 1)]).reshape((m1+_sm.Matrix([x,y]).reshape(2, 1)).shape[0], (m1+_sm.Matrix([x,y]).reshape(2, 1)).shape[1])
|
||||
a = (e3).diff(x)
|
||||
b = (e3).diff(y)
|
||||
cm = _sm.Matrix([i.diff(x) for i in m2]).reshape((m2).shape[0], (m2).shape[1])
|
||||
dm = _sm.Matrix([i.diff(x) for i in m1+_sm.Matrix([x,y]).reshape(2, 1)]).reshape((m1+_sm.Matrix([x,y]).reshape(2, 1)).shape[0], (m1+_sm.Matrix([x,y]).reshape(2, 1)).shape[1])
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
frame_b = _me.ReferenceFrame('b')
|
||||
frame_b.orient(frame_a, 'DCM', _sm.Matrix([1,0,0,1,0,0,1,0,0]).reshape(3, 3))
|
||||
v1 = x*frame_a.x+y*frame_a.y+x*y*frame_a.z
|
||||
e = (v1).diff(x, frame_b)
|
||||
fm = _sm.Matrix([i.diff(_sm.Symbol('t')) for i in m1]).reshape((m1).shape[0], (m1).shape[1])
|
||||
gm = _sm.Matrix([i.diff(_sm.Symbol('t')) for i in _sm.Matrix([(x+y)**2,(x-y)**2]).reshape(1, 2)]).reshape((_sm.Matrix([(x+y)**2,(x-y)**2]).reshape(1, 2)).shape[0], (_sm.Matrix([(x+y)**2,(x-y)**2]).reshape(1, 2)).shape[1])
|
||||
h = (v1).dt(frame_b)
|
||||
@@ -0,0 +1,41 @@
|
||||
% ruletest6.al
|
||||
VARIABLES Q{2}
|
||||
VARIABLES X,Y,Z
|
||||
Q1 = X^2 + Y^2
|
||||
Q2 = X-Y
|
||||
E = Q1 + Q2
|
||||
A = EXPLICIT(E)
|
||||
E2 = COS(X)
|
||||
E3 = COS(X*Y)
|
||||
A = TAYLOR(E2, 0:2, X=0)
|
||||
B = TAYLOR(E3, 0:2, X=0, Y=0)
|
||||
|
||||
E = EXPAND((X+Y)^2)
|
||||
A = EVALUATE(E, X=1, Y=Z)
|
||||
BM = EVALUATE([E;2*E], X=1, Y=Z)
|
||||
|
||||
E = Q1 + Q2
|
||||
A = EVALUATE(E, X=2, Y=Z^2)
|
||||
|
||||
CONSTANTS J,K,L
|
||||
P1 = POLYNOMIAL([J,K,L],X)
|
||||
P2 = POLYNOMIAL(J*X+K,X,1)
|
||||
|
||||
ROOT1 = ROOTS(P1, X, 2)
|
||||
ROOT2 = ROOTS([1;2;3])
|
||||
|
||||
M = [1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16]
|
||||
|
||||
AM = TRANSPOSE(M) + M
|
||||
BM = EIG(M)
|
||||
C1 = DIAGMAT(4, 1)
|
||||
C2 = DIAGMAT(3, 4, 2)
|
||||
DM = INV(M+C1)
|
||||
E = DET(M+C1) + TRACE([1,0;0,1])
|
||||
F = ELEMENT(M, 2, 3)
|
||||
|
||||
A = COLS(M)
|
||||
BM = COLS(M, 1)
|
||||
CM = COLS(M, 1, 2:4, 3)
|
||||
DM = ROWS(M, 1)
|
||||
EM = ROWS(M, 1, 2:4, 3)
|
||||
@@ -0,0 +1,36 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
q1, q2 = _me.dynamicsymbols('q1 q2')
|
||||
x, y, z = _me.dynamicsymbols('x y z')
|
||||
e = q1+q2
|
||||
a = (e).subs({q1:x**2+y**2, q2:x-y})
|
||||
e2 = _sm.cos(x)
|
||||
e3 = _sm.cos(x*y)
|
||||
a = (e2).series(x, 0, 2).removeO()
|
||||
b = (e3).series(x, 0, 2).removeO().series(y, 0, 2).removeO()
|
||||
e = ((x+y)**2).expand()
|
||||
a = (e).subs({q1:x**2+y**2,q2:x-y}).subs({x:1,y:z})
|
||||
bm = _sm.Matrix([i.subs({x:1,y:z}) for i in _sm.Matrix([e,2*e]).reshape(2, 1)]).reshape((_sm.Matrix([e,2*e]).reshape(2, 1)).shape[0], (_sm.Matrix([e,2*e]).reshape(2, 1)).shape[1])
|
||||
e = q1+q2
|
||||
a = (e).subs({q1:x**2+y**2,q2:x-y}).subs({x:2,y:z**2})
|
||||
j, k, l = _sm.symbols('j k l', real=True)
|
||||
p1 = _sm.Poly(_sm.Matrix([j,k,l]).reshape(1, 3), x)
|
||||
p2 = _sm.Poly(j*x+k, x)
|
||||
root1 = [i.evalf() for i in _sm.solve(p1, x)]
|
||||
root2 = [i.evalf() for i in _sm.solve(_sm.Poly(_sm.Matrix([1,2,3]).reshape(3, 1), x),x)]
|
||||
m = _sm.Matrix([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]).reshape(4, 4)
|
||||
am = (m).T+m
|
||||
bm = _sm.Matrix([i.evalf() for i in (m).eigenvals().keys()])
|
||||
c1 = _sm.diag(1,1,1,1)
|
||||
c2 = _sm.Matrix([2 if i==j else 0 for i in range(3) for j in range(4)]).reshape(3, 4)
|
||||
dm = (m+c1)**(-1)
|
||||
e = (m+c1).det()+(_sm.Matrix([1,0,0,1]).reshape(2, 2)).trace()
|
||||
f = (m)[1,2]
|
||||
a = (m).cols
|
||||
bm = (m).col(0)
|
||||
cm = _sm.Matrix([(m).T.row(0),(m).T.row(1),(m).T.row(2),(m).T.row(3),(m).T.row(2)])
|
||||
dm = (m).row(0)
|
||||
em = _sm.Matrix([(m).row(0),(m).row(1),(m).row(2),(m).row(3),(m).row(2)])
|
||||
@@ -0,0 +1,39 @@
|
||||
% ruletest7.al
|
||||
VARIABLES X', Y'
|
||||
E = COS(X) + SIN(X) + TAN(X)&
|
||||
+ COSH(X) + SINH(X) + TANH(X)&
|
||||
+ ACOS(X) + ASIN(X) + ATAN(X)&
|
||||
+ LOG(X) + EXP(X) + SQRT(X)&
|
||||
+ FACTORIAL(X) + CEIL(X) +&
|
||||
FLOOR(X) + SIGN(X)
|
||||
|
||||
E = SQR(X) + LOG10(X)
|
||||
|
||||
A = ABS(-1) + INT(1.5) + ROUND(1.9)
|
||||
|
||||
E1 = 2*X + 3*Y
|
||||
E2 = X + Y
|
||||
|
||||
AM = COEF([E1;E2], [X,Y])
|
||||
B = COEF(E1, X)
|
||||
C = COEF(E2, Y)
|
||||
D1 = EXCLUDE(E1, X)
|
||||
D2 = INCLUDE(E1, X)
|
||||
FM = ARRANGE([E1,E2],2,X)
|
||||
F = ARRANGE(E1, 2, Y)
|
||||
G = REPLACE(E1, X=2*X)
|
||||
GM = REPLACE([E1;E2], X=3)
|
||||
|
||||
FRAMES A, B
|
||||
VARIABLES THETA
|
||||
SIMPROT(A,B,3,THETA)
|
||||
V1> = 2*A1> - 3*A2> + A3>
|
||||
V2> = B1> + B2> + B3>
|
||||
A = DOT(V1>, V2>)
|
||||
BM = DOT(V1>, [V2>;2*V2>])
|
||||
C> = CROSS(V1>,V2>)
|
||||
D = MAG(2*V1>) + MAG(3*V1>)
|
||||
DYADIC>> = 3*A1>*A1> + A2>*A2> + 2*A3>*A3>
|
||||
AM = MATRIX(B, DYADIC>>)
|
||||
M = [1;2;3]
|
||||
V> = VECTOR(A, M)
|
||||
@@ -0,0 +1,35 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
x, y = _me.dynamicsymbols('x y')
|
||||
x_d, y_d = _me.dynamicsymbols('x_ y_', 1)
|
||||
e = _sm.cos(x)+_sm.sin(x)+_sm.tan(x)+_sm.cosh(x)+_sm.sinh(x)+_sm.tanh(x)+_sm.acos(x)+_sm.asin(x)+_sm.atan(x)+_sm.log(x)+_sm.exp(x)+_sm.sqrt(x)+_sm.factorial(x)+_sm.ceiling(x)+_sm.floor(x)+_sm.sign(x)
|
||||
e = (x)**2+_sm.log(x, 10)
|
||||
a = _sm.Abs(-1*1)+int(1.5)+round(1.9)
|
||||
e1 = 2*x+3*y
|
||||
e2 = x+y
|
||||
am = _sm.Matrix([e1.expand().coeff(x), e1.expand().coeff(y), e2.expand().coeff(x), e2.expand().coeff(y)]).reshape(2, 2)
|
||||
b = (e1).expand().coeff(x)
|
||||
c = (e2).expand().coeff(y)
|
||||
d1 = (e1).collect(x).coeff(x,0)
|
||||
d2 = (e1).collect(x).coeff(x,1)
|
||||
fm = _sm.Matrix([i.collect(x)for i in _sm.Matrix([e1,e2]).reshape(1, 2)]).reshape((_sm.Matrix([e1,e2]).reshape(1, 2)).shape[0], (_sm.Matrix([e1,e2]).reshape(1, 2)).shape[1])
|
||||
f = (e1).collect(y)
|
||||
g = (e1).subs({x:2*x})
|
||||
gm = _sm.Matrix([i.subs({x:3}) for i in _sm.Matrix([e1,e2]).reshape(2, 1)]).reshape((_sm.Matrix([e1,e2]).reshape(2, 1)).shape[0], (_sm.Matrix([e1,e2]).reshape(2, 1)).shape[1])
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
frame_b = _me.ReferenceFrame('b')
|
||||
theta = _me.dynamicsymbols('theta')
|
||||
frame_b.orient(frame_a, 'Axis', [theta, frame_a.z])
|
||||
v1 = 2*frame_a.x-3*frame_a.y+frame_a.z
|
||||
v2 = frame_b.x+frame_b.y+frame_b.z
|
||||
a = _me.dot(v1, v2)
|
||||
bm = _sm.Matrix([_me.dot(v1, v2),_me.dot(v1, 2*v2)]).reshape(2, 1)
|
||||
c = _me.cross(v1, v2)
|
||||
d = 2*v1.magnitude()+3*v1.magnitude()
|
||||
dyadic = _me.outer(3*frame_a.x, frame_a.x)+_me.outer(frame_a.y, frame_a.y)+_me.outer(2*frame_a.z, frame_a.z)
|
||||
am = (dyadic).to_matrix(frame_b)
|
||||
m = _sm.Matrix([1,2,3]).reshape(3, 1)
|
||||
v = m[0]*frame_a.x +m[1]*frame_a.y +m[2]*frame_a.z
|
||||
@@ -0,0 +1,38 @@
|
||||
% ruletest8.al
|
||||
FRAMES A
|
||||
CONSTANTS C{3}
|
||||
A>> = EXPRESS(1>>,A)
|
||||
PARTICLES P1, P2
|
||||
BODIES R
|
||||
R_A = [1,1,1;1,1,0;0,0,1]
|
||||
POINT O
|
||||
MASS P1=M1, P2=M2, R=MR
|
||||
INERTIA R, I1, I2, I3
|
||||
P_P1_O> = C1*A1>
|
||||
P_P2_O> = C2*A2>
|
||||
P_RO_O> = C3*A3>
|
||||
A>> = EXPRESS(I_P1_O>>, A)
|
||||
A>> = EXPRESS(I_P2_O>>, A)
|
||||
A>> = EXPRESS(I_R_O>>, A)
|
||||
A>> = EXPRESS(INERTIA(O), A)
|
||||
A>> = EXPRESS(INERTIA(O, P1, R), A)
|
||||
A>> = EXPRESS(I_R_O>>, A)
|
||||
A>> = EXPRESS(I_R_RO>>, A)
|
||||
|
||||
P_P1_P2> = C1*A1> + C2*A2>
|
||||
P_P1_RO> = C3*A1>
|
||||
P_P2_RO> = C3*A2>
|
||||
|
||||
B> = CM(O)
|
||||
B> = CM(O, P1, R)
|
||||
B> = CM(P1)
|
||||
|
||||
MOTIONVARIABLES U{3}
|
||||
V> = U1*A1> + U2*A2> + U3*A3>
|
||||
U> = UNITVEC(V> + C1*A1>)
|
||||
V_P1_A> = U1*A1>
|
||||
A> = PARTIALS(V_P1_A>, U1)
|
||||
|
||||
M = MASS(P1,R)
|
||||
M = MASS(P2)
|
||||
M = MASS()
|
||||
@@ -0,0 +1,49 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
c1, c2, c3 = _sm.symbols('c1 c2 c3', real=True)
|
||||
a = _me.inertia(frame_a, 1, 1, 1)
|
||||
particle_p1 = _me.Particle('p1', _me.Point('p1_pt'), _sm.Symbol('m'))
|
||||
particle_p2 = _me.Particle('p2', _me.Point('p2_pt'), _sm.Symbol('m'))
|
||||
body_r_cm = _me.Point('r_cm')
|
||||
body_r_f = _me.ReferenceFrame('r_f')
|
||||
body_r = _me.RigidBody('r', body_r_cm, body_r_f, _sm.symbols('m'), (_me.outer(body_r_f.x,body_r_f.x),body_r_cm))
|
||||
frame_a.orient(body_r_f, 'DCM', _sm.Matrix([1,1,1,1,1,0,0,0,1]).reshape(3, 3))
|
||||
point_o = _me.Point('o')
|
||||
m1 = _sm.symbols('m1')
|
||||
particle_p1.mass = m1
|
||||
m2 = _sm.symbols('m2')
|
||||
particle_p2.mass = m2
|
||||
mr = _sm.symbols('mr')
|
||||
body_r.mass = mr
|
||||
i1 = _sm.symbols('i1')
|
||||
i2 = _sm.symbols('i2')
|
||||
i3 = _sm.symbols('i3')
|
||||
body_r.inertia = (_me.inertia(body_r_f, i1, i2, i3, 0, 0, 0), body_r_cm)
|
||||
point_o.set_pos(particle_p1.point, c1*frame_a.x)
|
||||
point_o.set_pos(particle_p2.point, c2*frame_a.y)
|
||||
point_o.set_pos(body_r_cm, c3*frame_a.z)
|
||||
a = _me.inertia_of_point_mass(particle_p1.mass, particle_p1.point.pos_from(point_o), frame_a)
|
||||
a = _me.inertia_of_point_mass(particle_p2.mass, particle_p2.point.pos_from(point_o), frame_a)
|
||||
a = body_r.inertia[0] + _me.inertia_of_point_mass(body_r.mass, body_r.masscenter.pos_from(point_o), frame_a)
|
||||
a = _me.inertia_of_point_mass(particle_p1.mass, particle_p1.point.pos_from(point_o), frame_a) + _me.inertia_of_point_mass(particle_p2.mass, particle_p2.point.pos_from(point_o), frame_a) + body_r.inertia[0] + _me.inertia_of_point_mass(body_r.mass, body_r.masscenter.pos_from(point_o), frame_a)
|
||||
a = _me.inertia_of_point_mass(particle_p1.mass, particle_p1.point.pos_from(point_o), frame_a) + body_r.inertia[0] + _me.inertia_of_point_mass(body_r.mass, body_r.masscenter.pos_from(point_o), frame_a)
|
||||
a = body_r.inertia[0] + _me.inertia_of_point_mass(body_r.mass, body_r.masscenter.pos_from(point_o), frame_a)
|
||||
a = body_r.inertia[0]
|
||||
particle_p2.point.set_pos(particle_p1.point, c1*frame_a.x+c2*frame_a.y)
|
||||
body_r_cm.set_pos(particle_p1.point, c3*frame_a.x)
|
||||
body_r_cm.set_pos(particle_p2.point, c3*frame_a.y)
|
||||
b = _me.functions.center_of_mass(point_o,particle_p1, particle_p2, body_r)
|
||||
b = _me.functions.center_of_mass(point_o,particle_p1, body_r)
|
||||
b = _me.functions.center_of_mass(particle_p1.point,particle_p1, particle_p2, body_r)
|
||||
u1, u2, u3 = _me.dynamicsymbols('u1 u2 u3')
|
||||
v = u1*frame_a.x+u2*frame_a.y+u3*frame_a.z
|
||||
u = (v+c1*frame_a.x).normalize()
|
||||
particle_p1.point.set_vel(frame_a, u1*frame_a.x)
|
||||
a = particle_p1.point.partial_velocity(frame_a, u1)
|
||||
m = particle_p1.mass+body_r.mass
|
||||
m = particle_p2.mass
|
||||
m = particle_p1.mass+particle_p2.mass+body_r.mass
|
||||
@@ -0,0 +1,54 @@
|
||||
% ruletest9.al
|
||||
NEWTONIAN N
|
||||
FRAMES A
|
||||
A> = 0>
|
||||
D>> = EXPRESS(1>>, A)
|
||||
|
||||
POINTS PO{2}
|
||||
PARTICLES P{2}
|
||||
MOTIONVARIABLES' C{3}'
|
||||
BODIES R
|
||||
P_P1_PO2> = C1*A1>
|
||||
V> = 2*P_P1_PO2> + C2*A2>
|
||||
|
||||
W_A_N> = C3*A3>
|
||||
V> = 2*W_A_N> + C2*A2>
|
||||
W_R_N> = C3*A3>
|
||||
V> = 2*W_R_N> + C2*A2>
|
||||
|
||||
ALF_A_N> = DT(W_A_N>, A)
|
||||
V> = 2*ALF_A_N> + C2*A2>
|
||||
|
||||
V_P1_A> = C1*A1> + C3*A2>
|
||||
A_RO_N> = C2*A2>
|
||||
V_A> = CROSS(A_RO_N>, V_P1_A>)
|
||||
|
||||
X_B_C> = V_A>
|
||||
X_B_D> = 2*X_B_C>
|
||||
A_B_C_D_E> = X_B_D>*2
|
||||
|
||||
A_B_C = 2*C1*C2*C3
|
||||
A_B_C += 2*C1
|
||||
A_B_C := 3*C1
|
||||
|
||||
MOTIONVARIABLES' Q{2}', U{2}'
|
||||
Q1' = U1
|
||||
Q2' = U2
|
||||
|
||||
VARIABLES X'', Y''
|
||||
SPECIFIED YY
|
||||
Y'' = X*X'^2 + 1
|
||||
YY = X*X'^2 + 1
|
||||
|
||||
M[1] = 2*X
|
||||
M[2] = 2*Y
|
||||
A = 2*M[1]
|
||||
|
||||
M = [1,2,3;4,5,6;7,8,9]
|
||||
M[1, 2] = 5
|
||||
A = M[1, 2]*2
|
||||
|
||||
FORCE_RO> = Q1*N1>
|
||||
TORQUE_A> = Q2*N3>
|
||||
FORCE_RO> = Q2*N2>
|
||||
F> = FORCE_RO>*2
|
||||
@@ -0,0 +1,55 @@
|
||||
import sympy.physics.mechanics as _me
|
||||
import sympy as _sm
|
||||
import math as m
|
||||
import numpy as _np
|
||||
|
||||
frame_n = _me.ReferenceFrame('n')
|
||||
frame_a = _me.ReferenceFrame('a')
|
||||
a = 0
|
||||
d = _me.inertia(frame_a, 1, 1, 1)
|
||||
point_po1 = _me.Point('po1')
|
||||
point_po2 = _me.Point('po2')
|
||||
particle_p1 = _me.Particle('p1', _me.Point('p1_pt'), _sm.Symbol('m'))
|
||||
particle_p2 = _me.Particle('p2', _me.Point('p2_pt'), _sm.Symbol('m'))
|
||||
c1, c2, c3 = _me.dynamicsymbols('c1 c2 c3')
|
||||
c1_d, c2_d, c3_d = _me.dynamicsymbols('c1_ c2_ c3_', 1)
|
||||
body_r_cm = _me.Point('r_cm')
|
||||
body_r_cm.set_vel(frame_n, 0)
|
||||
body_r_f = _me.ReferenceFrame('r_f')
|
||||
body_r = _me.RigidBody('r', body_r_cm, body_r_f, _sm.symbols('m'), (_me.outer(body_r_f.x,body_r_f.x),body_r_cm))
|
||||
point_po2.set_pos(particle_p1.point, c1*frame_a.x)
|
||||
v = 2*point_po2.pos_from(particle_p1.point)+c2*frame_a.y
|
||||
frame_a.set_ang_vel(frame_n, c3*frame_a.z)
|
||||
v = 2*frame_a.ang_vel_in(frame_n)+c2*frame_a.y
|
||||
body_r_f.set_ang_vel(frame_n, c3*frame_a.z)
|
||||
v = 2*body_r_f.ang_vel_in(frame_n)+c2*frame_a.y
|
||||
frame_a.set_ang_acc(frame_n, (frame_a.ang_vel_in(frame_n)).dt(frame_a))
|
||||
v = 2*frame_a.ang_acc_in(frame_n)+c2*frame_a.y
|
||||
particle_p1.point.set_vel(frame_a, c1*frame_a.x+c3*frame_a.y)
|
||||
body_r_cm.set_acc(frame_n, c2*frame_a.y)
|
||||
v_a = _me.cross(body_r_cm.acc(frame_n), particle_p1.point.vel(frame_a))
|
||||
x_b_c = v_a
|
||||
x_b_d = 2*x_b_c
|
||||
a_b_c_d_e = x_b_d*2
|
||||
a_b_c = 2*c1*c2*c3
|
||||
a_b_c += 2*c1
|
||||
a_b_c = 3*c1
|
||||
q1, q2, u1, u2 = _me.dynamicsymbols('q1 q2 u1 u2')
|
||||
q1_d, q2_d, u1_d, u2_d = _me.dynamicsymbols('q1_ q2_ u1_ u2_', 1)
|
||||
x, y = _me.dynamicsymbols('x y')
|
||||
x_d, y_d = _me.dynamicsymbols('x_ y_', 1)
|
||||
x_dd, y_dd = _me.dynamicsymbols('x_ y_', 2)
|
||||
yy = _me.dynamicsymbols('yy')
|
||||
yy = x*x_d**2+1
|
||||
m = _sm.Matrix([[0]])
|
||||
m[0] = 2*x
|
||||
m = m.row_insert(m.shape[0], _sm.Matrix([[0]]))
|
||||
m[m.shape[0]-1] = 2*y
|
||||
a = 2*m[0]
|
||||
m = _sm.Matrix([1,2,3,4,5,6,7,8,9]).reshape(3, 3)
|
||||
m[0,1] = 5
|
||||
a = m[0, 1]*2
|
||||
force_ro = q1*frame_n.x
|
||||
torque_a = q2*frame_n.z
|
||||
force_ro = q1*frame_n.x + q2*frame_n.y
|
||||
f = force_ro*2
|
||||
Reference in New Issue
Block a user