MCPcopy Create free account
hub / github.com/Apress/python-for-matlab-development / main

Function main

code/dask/run_fr_dask.py:42–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40tic = default_timer
41
42def main():
43 T_total_s = tic()
44 model = 'one'
45 model = 'tiny'
46 model = 'sat.0'
47 model = 'satellite/satellite.7'
48 node_xy = read_tri(f'{model}.ele', f'{model}.node')[1]
49 solve_with = 'localhost' # localhost digitalocean coiled
50 solve_with = 'coiled' # localhost digitalocean coiled
51 n_jobs = 3
52 n_jobs = 2
53
54 load_history = np.loadtxt('data/load_hist_smoothed.txt')
55 n_FFT = 8192
56 n_FFT = 4096
57 n_FFT = 2048
58 n_freq = n_FFT // 2 # + 1 # only work up to Nyquist frequency
59 dT = 5.0e-4 # time between each load_history point
60 Time = np.arange(0, dT*n_FFT, dT)
61 Fs = 1/dT # sampling frequency
62 Hertz = np.linspace(0, Fs/2, num=n_freq) # only to Nyquist
63 dHz = Hertz[1]
64 print(f'Time: {n_FFT} times, 0.0 to {Time[-1]:.6f} sec steps of {dT:.6f} sec')
65 print(f'Freq: {n_freq} freq, 0.0 to {Hertz[-1]:.1f} Hz steps of {dHz:.1f} Hz')
66 print(f' {n_jobs} workers')
67
68 K, C, M, b, u_to_c = global_matrices(model)
69 P = np.fft.rfft(load_history, n=n_FFT)
70 P_Nyq = P[:n_freq] # only to Nyquist
71
72 keep_nodes = np.argwhere((np.abs(23.5 - node_xy[:,0]) < 1.5) *
73 (np.abs(10.5 - node_xy[:,1]) < 1.5)).ravel()
74 keep_dof_full = sorted(np.hstack([keep_nodes*2, keep_nodes*2+1]))
75 keep_dof = sorted([u_to_c[_] for _ in keep_dof_full]) # constrained DOF
76
77 if not len(keep_dof):
78 print('keep_dof is empty; expand radius')
79 return
80 print(f'keeping {len(keep_dof)} out of {K.shape[0]} DOF')
81
82 solnx = pysolve.remote_solve(solve_with, n_jobs, K, C, M, b,
83 P_Nyq, Hertz, keep_dof)
84 print(solnx)
85 toc('Total time = ', T_total_s)
86
87if __name__ == "__main__": main()

Callers 1

run_fr_dask.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected