Skip to content

Commit

Permalink
Bugfix to account for rotor yaw control in solve statics
Browse files Browse the repository at this point in the history
The rotor orientation is set internally depending on yaw_mode, but this was done only after computing the inertial properties of the system in solveStatics(). Consequently, the weight of the RNA was acting as if the turbine was at its initial position regardless of yaw_mode.
This commit fixes that, and now rotor orientation is updated before computing the inertial properties of the system. I'm still not sure if this fix is 100% correct, so this modification needs to be revised before merging rc1.3.2 into main.

The affected tests are the ones with wind in test_model.py. The corresponding true values were updated.
  • Loading branch information
lucas-carmo committed Dec 30, 2024
1 parent c3e9df7 commit b5d2591
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 54 deletions.
7 changes: 4 additions & 3 deletions raft/raft_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ def solveStatics(self, case, display=0):

X_initial[6*i:6*i+6] = np.array([fowt.x_ref, fowt.y_ref,0,0,0,0])
fowt.setPosition(X_initial[6*i:6*i+6]) # zero platform offsets
fowt.calcStatics()
fowt.calcTurbineConstants(case, ptfm_pitch=0) # for turbine forces >>> still need to update to use current fowt pose <<<
fowt.calcStatics() # Recompute statics because turbine heading may have changed due to yaw control

if statics_mod == 0:
K_hydrostatic.append(fowt.C_struc + fowt.C_hydro)
Expand All @@ -541,8 +542,7 @@ def solveStatics(self, case, display=0):
if display > 1:
print('Fowt ' + str(i))
print(case)

fowt.calcTurbineConstants(case, ptfm_pitch=0) # for turbine forces >>> still need to update to use current fowt pose <<<

fowt.calcHydroConstants()
F_env_constant[6*i:6*i+6] = np.sum(fowt.f_aero0, axis=1) + fowt.calcCurrentLoads(case)

Expand Down Expand Up @@ -639,6 +639,7 @@ def eval_func_equil(X, args):
case['wind_speed'] = caseorig['wind_speed'][i]

fowt.calcTurbineConstants(case, ptfm_pitch=r6[4]) # for turbine forces >>> still need to update to use current fowt pose <<<
fowt.calcStatics() # Recompute statics because turbine heading may have changed due to yaw control
fowt.calcHydroConstants() # prep for drag force and mean drift

Fnet[6*i:6*i+6] += np.sum(fowt.f_aero0, axis=1) # sum mean turbine force across turbines
Expand Down
14 changes: 8 additions & 6 deletions raft/raft_rotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,12 @@ def setPosition(self, r6=np.zeros(6), R=None):
# Store platform heading for use with nacelle yaw
self.platform_heading = r6[5]

# Apply nacelle yaw depending on the yaw mode
self.setYaw()

# Update RNA point locations [m] w.r.t. PRP in global orientations
self.r_RRP_rel = np.matmul(self.R_ptfm, self.r_rel) # RNA ref point
self.r_CG_rel = self.r_RRP_rel + self.q*self.xCG_RNA # RNA CG location
self.r_hub_rel = self.r_RRP_rel + self.q*self.overhang # rotor hub location


# Apply nacelle yaw depending on the yaw mode
self.setYaw()

'''
self.r_RRP = ? # RNA reference point
self.r_CG = ? # RNA CG location
Expand Down Expand Up @@ -456,6 +454,10 @@ def setYaw(self, yaw=None):
# Compute shaft axis unit vector in FOWT and global frames
self.q_rel = np.matmul(R_q_rel, np.array([1,0,0]) )
self.q = np.matmul(self.R_ptfm, self.q_rel) # Write in the global frame

# Update RNA point locations [m] w.r.t. PRP in global orientations
self.r_CG_rel = self.r_RRP_rel + self.q*self.xCG_RNA # RNA CG location
self.r_hub_rel = self.r_RRP_rel + self.q*self.overhang # rotor hub location

return self.yaw

Expand Down
Binary file modified tests/test_data/OC3spar_true_analyzeCases.pkl
Binary file not shown.
Binary file modified tests/test_data/VolturnUS-S_true_analyzeCases.pkl
Binary file not shown.
78 changes: 33 additions & 45 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def index_and_model(request):

desired_X0 = {
'wind': [
np.array([ 1.27859724e+01, 1.04743741e+01, -5.01461649e-01, -3.15384028e-02, 5.81281076e-02, -3.43746581e-02]),
np.array([ 1.10592890e+01, 5.11496586e+00, -8.09395988e-01, -2.24265993e-02, 3.99006197e-02, -9.07379936e-02]),
np.array([ 1.67865792e+01, 1.13731771e+01, 6.65488155e-01, -2.70207231e-02, 5.60311224e-02, -5.26038064e-02, 1.61811231e+03, 1.07724225e+01, 1.03879124e+00, -2.80596479e-02, 5.80909846e-02, 1.40253302e-02])
np.array([ 1.27981309e+01, 1.05301196e+01, -5.00955468e-01, -3.08123709e-02, 5.84502589e-02, -7.01593570e-03]),
np.array([ 1.09704957e+01, 5.30341749e+00, -8.08255233e-01, -2.20791574e-02, 4.00562243e-02, -1.88931043e-02]),
np.array([ 1.68407496e+01, 1.10109039e+01, 6.65635303e-01, -2.65746461e-02, 5.62504188e-02, -3.52280731e-02, 1.61816436e+03, 1.14496392e+01, 1.03847988e+00, -2.74957980e-02, 5.84431017e-02, 4.36756068e-02])
],
'wave': [
np.array([ 1.69712005e-02, -1.93781208e-17, -4.28261180e-01, -1.21300094e-18, 2.26746861e-05, -2.30847610e-23]),
Expand All @@ -85,9 +85,9 @@ def index_and_model(request):
np.array([ 3.24739802e+00, 1.08484956e+00, 8.42959914e-01, 7.16963134e-04, -1.22097638e-03, -5.87434156e-03, 1.60424961e+03, 1.10109258e+00, 9.21764906e-01, 7.58137041e-04, -2.11268701e-03, 6.56575162e-03])
],
'wind_wave_current': [
np.array([ 1.49997209e+01, 1.17238481e+01, -5.14214304e-01, -3.09044778e-02, 5.57397680e-02, -2.97221514e-02]),
np.array([ 1.52163136e+01, 5.51267781e+00, -8.60650288e-01, -2.27020326e-02, 4.08245936e-02, -9.32725846e-02]),
np.array([ 2.05122350e+01, 1.24080919e+01, 6.26685779e-01, -2.63488567e-02, 5.41410316e-02, -5.50626331e-02, 1.62214230e+03, 1.22408251e+01, 1.07732379e+00, -2.72746927e-02, 5.66805306e-02, 2.37652367e-02]),
np.array([ 1.50128997e+01, 1.17794646e+01, -5.13873441e-01, -3.01301643e-02, 5.60700058e-02, -3.19071097e-03]),
np.array([ 1.51819382e+01, 5.67973367e+00, -8.56976995e-01, -2.23553755e-02, 4.09788544e-02, -2.60679623e-02]),
np.array([ 2.05748182e+01, 1.20556081e+01, 6.26678004e-01, -2.58821266e-02, 5.43569306e-02, -3.84336757e-02, 1.62220604e+03, 1.29571972e+01, 1.07692445e+00, -2.66374984e-02, 5.70843751e-02, 5.55086139e-02])
]
}

Expand Down Expand Up @@ -128,9 +128,9 @@ def test_solveStatics_Wind_Wave_Current(index_and_model):
np.array([0.01074625, 0.00716318, 0.05084381, 0.03748606, 0.03783757, 0.01574022, 0.00756192, 0.00704588, 0.05086277, 0.03748700, 0.03779494, 0.01547133])
],
'loaded': [
np.array([0.00983736, 0.00711657, 0.06075493, 0.03838041, 0.03917049, 0.01328116]),
np.array([0.00730845, 0.00938709, 0.0324622 , 0.03384591, 0.03390244, 0.15556943]),
np.array([0.01065848, 0.0072143 , 0.05086057, 0.03789044, 0.03835428, 0.01772179, 0.00740685, 0.00644188, 0.05081992, 0.03679251, 0.03751652, 0.01330533])
np.array([0.00983467, 0.00711942, 0.06075478, 0.03837865, 0.03917143, 0.01326502]),
np.array([0.00730352, 0.00939103, 0.03246224, 0.03384297, 0.03390545, 0.1555763 ]),
np.array([0.01066207, 0.00721616, 0.05086057, 0.03789163, 0.03835356, 0.01771014, 0.00743523, 0.00644145, 0.05082023, 0.03678883, 0.03752444, 0.01331672])
],
}

Expand Down Expand Up @@ -162,42 +162,30 @@ def test_solveStatics_Wind_Wave_Current(index_and_model):
[-2.06368074e-18, -3.22196433e-03, 3.25247512e-19, 2.53764084e-03, -2.87786844e-17, 1.09079545e-01, -6.15608121e-17, -2.85012079e-03, -4.84193205e-19, 2.46503742e-03, 3.86906564e-17, -1.23225573e-01]])
],
'loaded': [
np.array([[-9.81922529e-01, -1.88477064e-01, 5.59814332e-03, 2.63748246e-01, -9.73655930e-01, -3.87082707e-01],
[ 1.89231078e-01, -9.82070660e-01, 2.97505444e-03, 9.53805742e-01, 1.85565530e-01, -6.74212470e-01],
[ 4.31094006e-03, 3.59103444e-03, 9.99979896e-01, -1.98260433e-02, 2.35679747e-02, 2.85386382e-02],
[ 2.07667634e-04, -5.06600871e-04, -5.42200927e-05, -1.37288737e-01, -2.49650348e-02, 1.19947617e-02],
[ 9.07418350e-04, 1.10221067e-04, 1.20498177e-04, 3.80792883e-02, -1.27985492e-01, 7.47856564e-03],
[-5.43821519e-04, -6.70936303e-04, -2.69410018e-05, 4.09428687e-04, 7.58604920e-04, 6.28164204e-01]]),
np.array([[-9.64511113e-01, -2.62972949e-01, -2.17836252e-02, 5.32494465e-01, 6.65652114e-01, -5.22431173e-03],
[ 2.63742574e-01, -9.64736977e-01, -9.50447095e-03, -8.46299535e-01, 7.45814008e-01, 1.88682345e-03],
[ 1.25631854e-02, 1.12200192e-02, 9.99717415e-01, 9.87477280e-04, 2.15061908e-02, -1.80917944e-03],
[ 1.44107118e-05, -8.44944185e-05, 1.89490724e-04, 1.20573641e-02, -1.06243716e-02, -1.76905542e-04],
[ 5.42775897e-05, 3.32352502e-05, -4.19851679e-04, 7.59840101e-03, 9.49345592e-03, -9.35690288e-05],
[ 5.74509767e-04, -1.37725479e-03, 1.26304547e-04, 4.75937331e-03, -1.79147442e-03, 9.99982916e-01]]),
np.array([[-7.72780208e-01, 1.35468412e-01, -1.77495566e-02, 4.22842581e-01, -7.32826057e-01, 1.07921591e-01, 5.95578887e-01, -1.87722800e-01, 4.79726175e-03, -1.83129519e-03, -1.72205796e-02, -1.44056530e-01],
[-2.28519471e-03, -9.77326843e-01, -1.74843237e-04, -8.88837415e-01, -6.53268410e-01, -9.54807874e-01, 2.05369622e-01, -6.41688285e-02, 3.56670017e-05, -3.02582744e-03, 2.46120155e-02, 6.30228760e-02],
[ 8.50862335e-03, -1.27740285e-03, -9.69677742e-01, -2.66634251e-02, 5.60030809e-02, -1.43192612e-02, -6.36785160e-03, 1.98135470e-03, 2.43677208e-01, -3.31096809e-03, 1.06565881e-02, 1.48729311e-03],
[-2.14147548e-07, -5.13051234e-04, 2.28569369e-05, 1.46348523e-01, 1.03860372e-01, -8.38713717e-03, 1.11521615e-04, -4.39100546e-05, -3.88676030e-06, 3.89544548e-04, -4.17391596e-03, -1.20687744e-04],
[ 3.50229130e-05, 4.81508566e-05, -2.96471440e-04, 7.95770662e-02, -1.38834167e-01, -2.81132282e-03, -2.08014641e-04, 7.50030410e-05, 1.16277632e-04, 1.13920287e-03, -7.01170226e-03, -8.83950465e-05],
[-8.25205229e-05, 2.97095677e-03, 5.83651248e-05, -4.00418833e-03, -2.30212529e-03, -2.40166282e-01, -2.55349690e-04, -1.02689336e-04, -1.45133749e-05, -7.17160421e-05, 1.72592987e-04, -3.61621868e-03],
[ 6.33918522e-01, 1.62082701e-01, -3.39536374e-03, 5.09072525e-02, -5.43724190e-02, 8.05114239e-02, 7.01183592e-01, -2.94123355e-01, -1.51879157e-02, -2.87259623e-01, 9.22402696e-01, 2.36651590e-01],
[-2.89806557e-02, -1.40197163e-02, 6.27951672e-04, -7.98679610e-03, 2.09851086e-03, 1.10471065e-01, -3.33697652e-01, -9.34933041e-01, 2.50812940e-03, -9.42830766e-01, -3.36459026e-01, -9.52181619e-01],
[ 6.12262049e-03, 1.54700079e-03, 2.43717017e-01, -2.73706238e-03, 5.41124848e-03, 7.14441628e-04, 7.03656560e-03, -1.60801493e-03, 9.69722323e-01, 6.75971380e-03, 4.42384895e-02, 4.03303739e-03],
[-7.31124374e-05, -2.43839230e-05, -2.50078305e-05, 9.22017629e-04, -4.24008169e-04, 4.83394158e-06, -2.41322773e-04, -4.82461803e-04, -9.63686678e-05, 1.57899450e-01, 5.19950014e-02, -6.52497993e-04],
[-6.60885996e-05, -3.13030222e-05, -4.59073676e-06, 5.58053584e-03, -3.54713531e-03, -2.21919732e-05, -1.89441252e-04, -6.23442736e-05, -1.80039164e-04, -5.95345943e-02, 1.73855081e-01, 1.09011091e-03],
[-1.74789101e-03, 2.81715003e-04, -9.04124903e-07, 9.27870178e-05, 1.81765117e-06, -6.72796711e-03, -2.50526577e-03, -5.23512364e-03, -4.85249735e-06, 2.19802909e-03, 1.10782634e-05, 1.12199961e-01]]),
np.array([[-7.72811610e-01, 1.41393935e-01, -1.77448545e-02, 4.16814597e-01, -7.31112620e-01, 1.16063188e-01, 5.94584233e-01, -1.86581467e-01, 4.79641782e-03, -1.97767472e-03, -1.66489013e-02, -1.36253924e-01],
[-2.87714383e-03, -9.75384474e-01, -1.47052786e-04, -8.91800458e-01, -6.55231561e-01, -9.53950275e-01, 2.14539220e-01, -6.35002554e-02, 2.83679231e-05, -3.03172142e-03, 2.43867571e-02, 6.29145314e-02],
[ 8.50714289e-03, -1.33371188e-03, -9.69681898e-01, -2.69481972e-02, 5.52001345e-02, -1.48513382e-02, -6.35890001e-03, 1.96906781e-03, 2.43661135e-01, -3.29086307e-03, 1.06839020e-02, 1.39118989e-03],
[ 2.76682885e-06, -5.11949394e-04, 1.81895770e-05, 1.46771949e-01, 1.04294678e-01, -8.38004516e-03, 1.13811511e-04, -4.27400619e-05, -2.68577189e-06, 3.87919652e-04, -4.13176783e-03, -1.20055852e-04],
[ 3.50209270e-05, 4.45102058e-05, -2.95736719e-04, 7.81880400e-02, -1.38696517e-01, -2.81435054e-03, -2.07566077e-04, 7.41403334e-05, 1.16088871e-04, 1.12666703e-03, -6.95586370e-03, -8.60577252e-05],
[-1.01071307e-04, 2.97278099e-03, 6.05949297e-05, -4.08318592e-03, -2.26650443e-03, -2.39856843e-01, -2.67800207e-04, -1.08377245e-04, -1.50836906e-05, -7.31632719e-05, 1.77062979e-04, -3.62290754e-03],
[ 6.33853776e-01, 1.68272957e-01, -3.39550283e-03, 4.96307547e-02, -5.41620294e-02, 8.02636391e-02, 7.00179405e-01, -2.93259206e-01, -1.51867240e-02, -2.89140044e-01, 9.24723567e-01, 2.37665124e-01],
[-2.95045824e-02, -1.74229529e-02, 6.22939884e-04, -7.63992421e-03, 2.05492440e-03, 1.10408825e-01, -3.31805602e-01, -9.35478473e-01, 2.49028810e-03, -9.42277858e-01, -3.29934057e-01, -9.53089376e-01],
[ 6.12040807e-03, 1.61001861e-03, 2.43700854e-01, -2.72246214e-03, 5.40410086e-03, 7.00015249e-04, 7.01985645e-03, -1.60878965e-03, 9.69726432e-01, 6.18386926e-03, 4.40569831e-02, 4.23944407e-03],
[-7.16317109e-05, -2.63248450e-05, -2.42200121e-05, 8.78714898e-04, -4.24314517e-04, 4.54694832e-06, -2.38273158e-04, -4.83749124e-04, -9.37329246e-05, 1.57710359e-01, 5.11775274e-02, -6.52243965e-04],
[-6.46851669e-05, -3.30541306e-05, -4.57568389e-06, 5.43236832e-03, -3.53689068e-03, -2.23866309e-05, -1.87599602e-04, -5.77467140e-05, -1.79935229e-04, -5.97447838e-02, 1.74408007e-01, 1.09485156e-03],
[-1.71938462e-03, 2.49209378e-04, -1.38408991e-06, 8.75424867e-05, 8.14297749e-06, -6.73389531e-03, -2.53410362e-03, -5.23613641e-03, -6.63627886e-06, 2.20871027e-03, -3.33064438e-05, 1.12151147e-01]])
np.array([[ 9.81639518e-01, -1.90667569e-01, 5.58635270e-03, -2.16960992e-01, -9.69645100e-01, 2.37939853e-01],
[-1.90694149e-01, -9.81647754e-01, 2.99413815e-03, -9.65528488e-01, 2.05596001e-01, -6.23831444e-01],
[-4.32526222e-03, 3.62729497e-03, 9.99979905e-01, 1.91932750e-02, 2.27486960e-02, 3.72816030e-03],
[-1.85483819e-04, -5.04396308e-04, -5.71588748e-05, 1.39107957e-01, -2.72889617e-02, 1.42417390e-02],
[-9.21676930e-04, 9.45385064e-05, 1.18833713e-04, -3.10320447e-02, -1.27499112e-01, 8.02033132e-03],
[-8.42648011e-05, -3.80015575e-04, -3.09533732e-06, -5.23051246e-04, 6.70612966e-04, 7.44270048e-01]]),
np.array([[-9.64378242e-01, -2.63590752e-01, -2.10946483e-02, 6.67618956e-01, 7.11326547e-01, -3.97038343e-03],
[ 2.64226439e-01, -9.64567735e-01, -1.08535955e-02, -7.44333038e-01, 7.02378251e-01, 2.46425477e-03],
[ 1.25912062e-02, 1.12874097e-02, 9.99718461e-01, 5.36744834e-03, 2.17700278e-02, -4.08761745e-04],
[ 1.12508015e-05, -8.58285900e-05, 2.09146973e-04, 1.06044546e-02, -1.00067204e-02, -1.76052849e-04],
[ 5.54046589e-05, 2.84236886e-05, -4.10342190e-04, 9.52540836e-03, 1.01447352e-02, -8.89069168e-05],
[ 6.73636151e-04, -1.25989426e-03, 3.44483770e-05, 4.61085742e-03, -1.53377328e-03, 9.99988979e-01]]),
np.array([[ 7.70854059e-01, -1.07812429e-01, -1.77350920e-02, 4.61488770e-01, -7.63899755e-01, -6.95967137e-02, 5.96511338e-01, -2.06063675e-01, 4.83434640e-03, 9.11089053e-04, -1.64189060e-02, -1.91827040e-01],
[ 7.12894630e-04, 9.85495892e-01, -1.70569554e-04, -8.69004513e-01, -6.15773931e-01, 9.59986560e-01, 1.60092808e-01, -6.58931415e-02, 3.85255071e-05, 2.69400183e-03, 2.07853900e-02, 6.42269549e-02],
[-8.49004639e-03, 1.03127643e-03, -9.69149072e-01, -2.89598744e-02, 5.83786886e-02, 1.04835127e-02, -6.37368931e-03, 2.17759940e-03, 2.45771736e-01, 3.19500877e-03, 1.04316961e-02, 2.07860190e-03],
[ 1.10847995e-06, 5.18097972e-04, 2.50680055e-05, 1.42863424e-01, 9.82807749e-02, 8.34570035e-03, 8.61679818e-05, -4.44663162e-05, -5.10282407e-06, -3.29505827e-04, -3.52504651e-03, -1.24295242e-04],
[-3.54854708e-05, -4.13208082e-05, -2.95584349e-04, 8.70726154e-02, -1.44554441e-01, 2.81498585e-03, -2.01642662e-04, 8.14607760e-05, 1.16823232e-04, -1.13803058e-03, -6.86652703e-03, -1.01259382e-04],
[ 4.40951734e-05, -2.96826452e-03, 4.33851404e-05, -3.97247702e-03, -2.14221686e-03, 2.40287363e-01, -2.57087136e-04, -6.23931448e-05, -1.08806459e-05, 6.31744509e-05, 1.40409394e-04, -3.72663034e-03],
[-6.36164823e-01, -1.30976836e-01, -3.43526092e-03, 5.38615203e-02, -5.70951162e-02, -5.77084868e-02, 6.96414716e-01, -3.16333319e-01, -1.52114930e-02, 2.54386914e-01, 9.13458876e-01, 1.71545373e-01],
[ 3.10558308e-02, 2.74403116e-03, 6.16245587e-04, -8.32132056e-03, 2.13959116e-03, -1.10817902e-01, -3.65315185e-01, -9.23630791e-01, 2.41710349e-03, 9.52370375e-01, -3.60638566e-01, -9.57266208e-01],
[-6.19874722e-03, -1.23086225e-03, 2.45811398e-01, -2.91685570e-03, 5.73531313e-03, -6.61072333e-04, 7.09727546e-03, -1.70528912e-03, 9.69193270e-01, -5.15961019e-03, 4.38259206e-02, 5.00531709e-04],
[ 6.07068762e-05, 1.31255225e-05, -2.24894180e-05, 9.41804232e-04, -3.82564624e-04, -9.46639158e-06, -2.43595956e-04, -4.77939019e-04, -8.11900260e-05, -1.59702991e-01, 5.51650815e-02, -6.65205950e-04],
[ 6.86645321e-05, 2.24822361e-05, -5.72790751e-06, 5.78808453e-03, -3.79483287e-03, 3.58925623e-05, -1.97483474e-04, -7.66275028e-05, -1.82794774e-04, 5.21713847e-02, 1.72333332e-01, 1.18660611e-03],
[ 1.68761387e-03, -4.53419690e-04, 6.05608833e-06, 1.18365474e-04, -4.51452573e-05, 6.72993925e-03, -2.16024254e-03, -5.22996657e-03, 2.18283821e-05, -2.17776795e-03, -4.85272172e-05, 1.15197842e-01]])
],
}

Expand Down

0 comments on commit b5d2591

Please sign in to comment.