ebranlard / wtDigiTwin

A wind turbine digital twin based on YAMS
MIT License
26 stars 4 forks source link

TypeError: unsupported operand type(s) for -: 'tuple' and 'int' #3

Closed Liamkk closed 3 months ago

Liamkk commented 3 months ago

Hello When I run the example file "301_Kalman_2DOF_5States" and "300_Kalman_2DOF_7States", the process abort. The run output showes that:

Time step 0 t= 0.000 WS= 7.9 Thrust=401615.5 Time step 500 t= 25.000 WS= 7.8 Thrust=366735.2 Traceback (most recent call last): File "E:/DeskStudy/CGN/wtDigiTwin/wtDigiTwin-1.0/examples/onshore_OFLin/301_Kalman_2DOF_5States.py", line 105, in KF= KalmanFilterTNLinSim(KM, FstFile, MeasFile, OutputFile, base, StateFile, nUnderSamp, tRange, bFilterAcc, nFilt, NoiseRFactor, sigX, sigY, bExport) File "e:\deskstudy\cgn\wtdigitwin\wtdigitwin-1.0\welib\welib\kalman\TNLin.py", line 467, in KalmanFilterTNLinSim KF.moments() File "e:\deskstudy\cgn\wtdigitwin\wtdigitwin-1.0\welib\welib\kalman\TNLin.py", line 239, in moments z_test = fastlib.ED_TwrGag(WT.ED) - WT.ED['TowerBsHt'] TypeError: unsupported operand type(s) for -: 'tuple' and 'int' [TIME] Simulation Loop Elapsed: 1.97s

Liamkk commented 3 months ago

Change the code in TNLin.py, line 239 and line 411 z_test = list(fastlib.ED_TwrGag(KF.WT.ED)[-1] - KF.WT.ED['TowerBsHt'])

The issue is closed.

ebranlard commented 3 months ago

Hi,

Thanks for reporting this. In fact, you would need to ensure the TwrGag is a numpy array instead of a list. You can do this with np.asarray. Feel free to submit a pull request.