74 global SourceDir, BuildDir, N
75 global ProgDuration, SymDuration, NTimesteps, FunCount, FunBatch
76 global QMax, QMin, I0, QInitValues, QFinalValues
81 q = (QMax + QMin) / 2. + (QMax - QMin) / 2. * np.cos(x)
84 q_ext_1 = np.hstack((QInitValues[0], q[:N], QFinalValues[0]))
85 q_ext_2 = np.hstack((QInitValues[1], q[N:], QFinalValues[1]))
88 I_1 = 0.5 * I0 * (1 + q_ext_2*q_ext_2)
89 I_2 = 0.5 * I0 * (1 + q_ext_1*q_ext_1)
90 I_3 = 0.5 * I0 * (q_ext_1*q_ext_1 + q_ext_2*q_ext_2)
91 nodal_values = np.hstack((I_1, I_2, I_3))
92 print(
"Nodal values of principal moments of inertia:", nodal_values)
95 xx, n_I1, n_I2, n_I3, xc, I1, dI1, I2, dI2, I3, dI3 =
ComputeInertiaProfiles(nodal_values, ProgDuration, NTimesteps)
97 arr = np.transpose(np.vstack((xc, I1, I2, I3, dI1, dI2, dI3)))
100 I1_ext = np.hstack((I1, I1[len(I1)-1] * np.ones((int) (NTimesteps * (SymDuration - ProgDuration) / SymDuration))))
101 I2_ext = np.hstack((I2, I2[len(I2)-1] * np.ones((int) (NTimesteps * (SymDuration - ProgDuration) / SymDuration))))
102 I3_ext = np.hstack((I3, I3[len(I3)-1] * np.ones((int) (NTimesteps * (SymDuration - ProgDuration) / SymDuration))))
103 T_I = np.arange(0, SymDuration, SymDuration / len(I1_ext))
106 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/inertia_profiles.txt', arr)
107 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/I_1.txt', I1_ext)
108 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/I_2.txt', I2_ext)
109 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/I_3.txt', I3_ext)
110 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/T_I.txt', T_I)
111 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/nodal_values.txt', nodal_values)
116 os.chdir(BuildDir +
'/Drivers/Clump/ChangingTOI')
117 command = [BuildDir +
'/Drivers/Clump/ChangingTOI/ChangingTOI']
118 command.append(
'-p1')
119 command.append(
str(ProgDuration))
120 command.append(
'-p2')
121 command.append(
str(SymDuration))
122 command.append(
'-p3')
123 command.append(
str(BaseAngvel))
125 subprocess.run(command)
128 f = open(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/functional.txt',
"r")
129 ret = float(f.read())
135 FunBatch = np.append(FunBatch, ret)
136 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/fun_batch.txt', FunBatch)
str
Definition: compute_granudrum_aor.py:141