-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenario_line_elastic_fresnel.py
52 lines (41 loc) · 2.11 KB
/
scenario_line_elastic_fresnel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# -*- coding: utf8 -*-
"""
Sur une ligne de lames, on fait tourner les lames avec un mouvement relativement élastique mais exogene (prédeterminé, pas émergent)
"""
import elasticite as el
import numpy as np
duration = el.get_default_args(el.EdgeGrid.render)['duration']
location = el.get_default_args(el.EdgeGrid.render)['location']
class EdgeGrid(el.EdgeGrid):
def champ(self):
if self.structure: N_lame = self.N_lame-self.struct_N
else: N_lame = self.N_lame
force = np.zeros_like(self.lames[2, :N_lame])
damp_min = 0.01
damp_tau = 1.5
damp_angle_tau = 14.
damp = lambda t: damp_min + (1.-damp_min)*np.exp(-np.abs(np.mod(t+self.period/2, self.period)-self.period/2)/damp_tau)
damp_angle = lambda t: 1.-np.exp(-(np.mod(t+self.period/2, self.period)-self.period/2)**2/2/damp_angle_tau**2)
xf = lambda t: location[0]
zf = lambda t: location[2] + 3.5 * np.sin(2*np.pi*(t)/self.period)
smooth_tau = 15
smooth = lambda t: 1.-np.exp(-np.abs(np.mod(t+self.period/2, self.period)-self.period/2)**2/smooth_tau**2)
desired_angle = np.arctan2(self.lames[1, :N_lame]-zf(self.t), self.lames[0, :N_lame]-xf(self.t)) - np.pi/2
# self.lames[2, :N_lame] = np.mod(self.lames[2, :]-np.pi/2, np.pi) + np.pi/2
#print (damp_angle(self.t), desired_angle)
force += (damp_angle(self.t)*(np.mod(desired_angle+np.pi/2, np.pi) - np.pi/2) - self.lames[2, :N_lame]) *smooth(self.t)
force -= 12 * (np.mod(self.lames[2, :N_lame]+np.pi/2, np.pi) - np.pi/2) * (1- smooth(self.t) )
#print (force)
force -= damp(self.t) * self.lames[3, :N_lame]/self.dt
#force *= damp_force(self.t) #* self.lames[3, :N_lame]/self.dt
# print (damp(self.t), self.t, self.period)
return 3. * force
if __name__ == "__main__":
import sys
if len(sys.argv)>1: mode = sys.argv[1]
else: mode = 'both'
filename = None
filename = 'mat/line_fresnelastique.npy'
e = EdgeGrid(N_lame=25, grid_type='line', mode=mode, verb=False, filename=filename, period=120.)
el.main(e)