125 global SourceDir, BuildDir, N
126 global ProgDuration, SymDuration, NTimesteps, FunCount, FunBatch
127 global QMax, QMin, I0, QInitValues, QFinalValues
132 q = (QMax + QMin) / 2. + (QMax - QMin) / 2. * np.cos(x)
135 q_ext_1 = np.hstack((QInitValues[0], q[:N], QFinalValues[0]))
136 q_ext_2 = np.hstack((QInitValues[1], q[N:], QFinalValues[1]))
139 I_1 = 0.5 * I0 * (1 + q_ext_2*q_ext_2)
140 I_2 = 0.5 * I0 * (1 + q_ext_1*q_ext_1)
141 I_3 = 0.5 * I0 * (q_ext_1*q_ext_1 + q_ext_2*q_ext_2)
142 nodal_values = np.hstack((I_1, I_2, I_3))
143 print(
"Nodal values of principal moments of inertia:", nodal_values)
146 xx, n_I1, n_I2, n_I3, xc, I1, dI1, I2, dI2, I3, dI3 =
ComputeInertiaProfiles(nodal_values, ProgDuration, NTimesteps)
148 arr = np.transpose(np.vstack((xc, I1, I2, I3, dI1, dI2, dI3)))
151 I1_ext = np.hstack((I1, I1[len(I1)-1] * np.ones((int) (NTimesteps * (SymDuration - ProgDuration) / SymDuration))))
152 I2_ext = np.hstack((I2, I2[len(I2)-1] * np.ones((int) (NTimesteps * (SymDuration - ProgDuration) / SymDuration))))
153 I3_ext = np.hstack((I3, I3[len(I3)-1] * np.ones((int) (NTimesteps * (SymDuration - ProgDuration) / SymDuration))))
154 T_I = np.arange(0, SymDuration, SymDuration / len(I1_ext))
157 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/inertia_profiles.txt', arr)
158 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/I_1.txt', I1_ext)
159 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/I_2.txt', I2_ext)
160 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/I_3.txt', I3_ext)
161 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/T_I.txt', T_I)
162 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/nodal_values.txt', nodal_values)
167 os.chdir(BuildDir +
'/Drivers/Clump/ChangingTOI')
168 command = [BuildDir +
'/Drivers/Clump/ChangingTOI/ChangingTOI']
169 command.append(
'-p1')
170 command.append(
str(ProgDuration))
171 command.append(
'-p2')
172 command.append(
str(SymDuration))
173 command.append(
'-p3')
174 command.append(
str(BaseAngvel))
176 subprocess.run(command)
179 f = open(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/functional.txt',
"r")
180 ret = float(f.read())
186 FunBatch = np.append(FunBatch, ret)
187 np.savetxt(BuildDir +
'/Drivers/Clump/ChangingTOI/opt/fun_batch.txt', FunBatch)
def RealFun(x)
Definition: MultiOpt.py:122
str
Definition: compute_granudrum_aor.py:141