-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscenario_line_geometry_90deg.py
39 lines (30 loc) · 1.41 KB
/
scenario_line_geometry_90deg.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
#!/usr/bin/env python
# -*- coding: utf8 -*-
import elasticite as el
import numpy as np
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.7
damp_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)
smooth = lambda t: 1.-np.exp(-np.abs(np.mod(t+self.period/2, self.period)-self.period/2)**2/damp_tau**2)
on_off = lambda t, freq: (np.sin(2*np.pi*t/self.period*freq) > 0.)
noise = lambda t: .2 * smooth(t)
force -= 7.5 * (np.mod(self.lames[2, :N_lame], np.pi) -np.pi/2 ) *smooth(self.t) * on_off(self.t, 3)
force -= 40 * (np.mod(self.lames[2, :N_lame]+np.pi/2, np.pi) - np.pi/2) * (1- smooth(self.t) ) * (1-on_off(self.t, 3))
force += noise(self.t)*np.pi*np.random.randn(N_lame)
force -= damp(self.t) * self.lames[3, :N_lame]/self.dt
force *= .01
force = 2 * np.tanh(force)
return force
if __name__ == "__main__":
import sys
if len(sys.argv)>1: mode = sys.argv[1]
else: mode = 'both'
filename = None
filename = 'mat/line_geometry_90deg.npy'
e = EdgeGrid(N_lame=25, grid_type='line', mode=mode, verb=False, filename=filename, period=4*60.)
el.main(e)