simplify uses
This commit is contained in:
parent
96bc3c2620
commit
bae3b143c6
5 changed files with 13 additions and 10 deletions
|
|
@ -29,8 +29,8 @@ V += m2 * g * x2
|
|||
L = T - V
|
||||
|
||||
init = {
|
||||
"theta1" : [-3 * np.pi/4, 0], # theta1, theta1.diff()
|
||||
"theta2" : [-np.pi/2, 0], # theta2, theta2.diff()
|
||||
theta1 : [-3 * np.pi/4, 0], # theta1, theta1.diff()
|
||||
theta2 : [-np.pi/2, 0], # theta2, theta2.diff()
|
||||
}
|
||||
|
||||
dt = 0.01
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ V += k2 * (r2 - r20) * (r2 - r20)
|
|||
L = T - V
|
||||
|
||||
init = {
|
||||
"theta1" : [- np.pi/4, 0],
|
||||
"theta2" : [- np.pi/4, 0],
|
||||
"r1" : [1, 0],
|
||||
"r2" : [1, 0],
|
||||
theta1 : [- np.pi/4, 0],
|
||||
theta2 : [- np.pi/4, 0],
|
||||
r1 : [1, 0],
|
||||
r2 : [1, 0],
|
||||
}
|
||||
|
||||
dt = 0.001
|
||||
|
|
|
|||
|
|
@ -201,6 +201,9 @@ class Var:
|
|||
|
||||
def __hash__(self):
|
||||
return hash((self.name, self.degree))
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def __add__(self, other):
|
||||
if other.type == "Const":
|
||||
|
|
@ -470,7 +473,7 @@ class Equation:
|
|||
dico = {}
|
||||
for v_name, v_init in init.items():
|
||||
for i in range(len(v_init)):
|
||||
dico["d_"*i + v_name] = v_init[i]
|
||||
dico["d_"*i + str(v_name)] = v_init[i]
|
||||
|
||||
self.simplify()
|
||||
variables = self.getAllVar()
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ V = m * g * r * lgc.cos(theta) + k * (r - r0) * (r - r0)
|
|||
L = T - V
|
||||
|
||||
init = {
|
||||
"theta" : [-3.14/2, 0], # theta, theta.diff()
|
||||
"r" : [1.2, 0], # r, r.diff()
|
||||
theta : [-3.14/2, 0], # theta, theta.diff()
|
||||
r : [1.2, 0], # r, r.diff()
|
||||
}
|
||||
|
||||
dt = 0.001
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ V = m * g * r * lgc.cos(theta)
|
|||
L = T - V
|
||||
|
||||
init = {
|
||||
"theta" : [-3 * 3.14/4, 0], # theta, theta.diff()
|
||||
theta : [-3 * 3.14/4, 0], # theta, theta.diff()
|
||||
}
|
||||
|
||||
dt = 0.01
|
||||
|
|
|
|||
Loading…
Reference in a new issue