-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiber_config_OutputReduction.py
More file actions
87 lines (66 loc) · 2.79 KB
/
Copy pathfiber_config_OutputReduction.py
File metadata and controls
87 lines (66 loc) · 2.79 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
import pickle
import argparse
import multiprocessing
import json
import numpy as np
from fiber_simulation_main import fiber_simulation
from utils.unit_scaling import unit_scaling
def wrapper_launcher(params):
try:
sim = fiber_simulation(**params)
sim.launch_sim()
except Exception as e:
print(f'Something failed!, Error: {e}')
return
def mp_handler(params_list):
p = multiprocessing.Pool(1)
p.map(wrapper_launcher, params_list)
if __name__ == '__main__':
parent_folder = "Simulations/SAGE/OutputReduction/"
parser = argparse.ArgumentParser(description="Script that configures and launches fiber_simulation for output reduction analysis")
parser.add_argument("--num_threads", required=True, type=int)
parser.add_argument("--point_force_mag", required=True, type=int)
args = parser.parse_args()
num_threads = args.num_threads
point_force_mag = args.point_force_mag / 10 #0.085
num_horizontal_threads = num_threads
num_vertical_threads = num_horizontal_threads
thread_length = 500e-3
dx = 10e-3
scaling_type = "mm_g_s"
params = {
'num_horizontal_threads': num_horizontal_threads,
'num_vertical_threads': num_vertical_threads,
'network_origin': np.zeros((3,)), # network_origin is the center of the network
'thread_length': thread_length, # 1 m --> 1e3 mm
'thread_diameter': 2e-3, # 1 m --> 1e3 mm
'dx': dx, # 1 m --> 1e3 mm
'youngs_modulus': 100e6, # 1 Pa = kg /m/s2 --> 1 g/mm/s2 --> 1e-3 mg/mm/ms2
'density': 1e3, # 1 kg / mm3 --> 1e-6 g/mm3 --> 1e-3 mg/mm3
'tension_force': 1e-2, # 1 N = kg m/s2 --> 1e6 g mm/s2 --> 1e3 mg mm /ms2
'point_force_mag': -point_force_mag, # 1 N = kg m/s2 --> 1e6 g mm/s2 --> 1e3 mg mm /ms2
'SPREAD_PF': True, # whether the force should be a gaussian spread across 5 nodes or just applied at a single point
'TYPE_PF': "spline", # type of force to be applied
'sample_freq_pf': 5, # Sampling frequency for random point force
'damping_constant': 10,
'filter_order': 6,
'k': 1e9, # translational stiffness of connection
'kt': 1e9, # rotational stiffness of connection
'nu': 0.0, # translational damping of connection
'duration': 100, # 1 s --> 1e3 ms
'sim_dt': 5e-6, # simulation timestep
'rendering_fps': 250,
'STOP_AT_NAN': True,
'SAVE': True,
'VIDEO': False,
'scaling_type': scaling_type,
'loc': f'{parent_folder}/Data/',
'file_type': 'npz',
}
params = unit_scaling.scale(params=params, scaling_type=scaling_type)
params_list = [params]
''' Launching the simulation'''
# mp_handler(params_list)
sim = fiber_simulation(**params)
sim.launch_sim()