Skip to content

Loads: mler_coefficients phase calculation has wrong sign (negative instead of positive) #172

@simmsa

Description

@simmsa

The test_mler_coefficients() test fails because many of the calculated phase values are negative when the validation data expects positive values. The calculated values are close to the negative of expected values.

function test_mler_coefficients(testCase)
% `mler_coefficients` Line 54, 55
% phase delay should be positive number
% phase = -unwrap(angle(RAO));
% Per @simmsa, this does not perform this conversion correctly for positive RAO values
assumeFail(testCase, "Per @simmsa, ask @hivanov about setting RAO to negative values per the above comment");
% create inputs and load validation data
fpath = '../../examples/data/loads/mler.csv';
validation = readtable(fpath);
wave_freq = linspace(0,1,500);
js = jonswap_spectrum(wave_freq,15.1,9);
response_desired = 1;
RAO = validation.RAO;
RAO = RAO';
% execute function
mler = mler_coefficients(RAO, js, response_desired);
% assertions
assertEqual(testCase, mler.conditioned_spectrum, validation.Res_Spec', 'RelTol',0.005)
assertEqual(testCase, mler.phase, validation.phase', 'RelTol',0.001)
end

================================================================================
Assertion failed in Loads_TestExtreme/test_mler_coefficients and it did not run to completion.
    ---------------------
    Framework Diagnostic:
    ---------------------
    assertEqual failed.
    --> The numeric values are not equal using "isequaln".
    --> The error was not within relative tolerance.
    --> Failure table (First 50 out of 499 failed indices):
            Index           Actual              Expected              Error              RelativeError      RelativeTolerance
            _____    _____________________    ____________    _____________________    _________________    _________________
                                                                                                                             
             2       -0.000224700554874433    0.000224701     -0.000449401554874433    -1.99999801903166          0.001      
             3       -0.000392122769765216    0.000392123     -0.000784245769765216    -1.9999994128506           0.001      
             4       -0.000510693802738911    0.000510694     -0.00102138780273891     -1.99999961373917          0.001      
             5       -0.000588840811862077    0.000588841     -0.00117768181186208     -1.99999968049453          0.001      
             6       -0.000634990955201273    0.000634991     -0.00126998195520127     -1.99999992944982          0.001      
             7       -0.000657571390823059    0.000657571     -0.00131514239082306     -2.00000059434351          0.001      
             8       -0.000665009276793997    0.000665009     -0.001330018276794       -2.00000041622594          0.001      
             9       -0.0008200481728313      0.000820048     -0.0016400961728313      -2.00000021075754          0.001      
             10      -0.000949085850235464    0.000949086     -0.00189817185023546     -1.9999998422013           0.001      
             11      -0.00123230328236302     0.001232303     -0.00246460628236302     -2.00000022913441          0.001      
             12      -0.00140189792379037     0.001401898     -0.00280379592379037     -1.99999994563825          0.001      
             13      -0.00176849289306414     0.001768493     -0.00353698589306414     -1.99999993953278          0.001      
             14      -0.00203051807713144     0.002030518     -0.00406103607713144     -2.00000003798609          0.001      
             15      -0.00237729200152515     0.002377292     -0.00475458400152515     -2.00000000064155          0.001      
             16      -0.00271359768181828     0.002713598     -0.00542719568181828     -1.99999988274545          0.001      
             17      -0.00317708975498676     0.00317709      -0.00635417975498676     -1.99999992288124          0.001      
             18      -0.00364240991212135     0.00364241      -0.00728481991212135     -1.99999997587349          0.001      
             19      -0.00409416804062982     0.004094168     -0.00818833604062982     -2.00000000992383          0.001      
             20      -0.00462856220868233     0.004628562     -0.00925712420868233     -2.00000004508578          0.001      
             21      -0.00524423530485101     0.005244235     -0.010488470304851       -2.00000005813069          0.001      
             22      -0.00582594818784345     0.005825948     -0.0116518961878434      -2.00000003224255          0.001      
             23      -0.00652650634900939     0.006526506     -0.0130530123490094      -2.00000005347569          0.001      
             24      -0.00729889889043891     0.007298899     -0.0145977978904389      -1.99999998498937          0.001      
             25      -0.00804282248243862     0.008042822     -0.0160856444824386      -2.00000005998375          0.001      
             26      -0.00890869652455034     0.008908697     -0.0178173935245503      -1.99999994663084          0.001      
             27      -0.00975469790383186     0.009754698     -0.0195093959038319      -1.99999999014135          0.001      
             28      -0.0108416905059598      0.010841691     -0.0216833815059598      -1.99999995443145          0.001      
             29      -0.0119015396045846      0.01190154      -0.0238030796045846      -1.99999996677612          0.001      
             30      -0.0130175610264211      0.013017561     -0.0260351220264211      -2.00000000202965          0.001      
             31      -0.0143657642252843      0.014365764     -0.0287315282252843      -2.00000001568202          0.001      
             32      -0.015809314806658       0.015809315     -0.031618629806658       -1.99999998777038          0.001      
             33      0.000327255899107794     -0.000327256    0.000654511899107794     -1.9999996917025           0.001      
             34      -0.00131181308575236     0.001311813     -0.00262362608575236     -2.00000006536934          0.001      
             35      -0.00300742308808337     0.003007423     -0.00601484608808337     -2.00000002928865          0.001      
             36      -0.00486593209829286     0.004865932     -0.00973186409829286     -2.00000002020021          0.001      
             37      -0.00676562681836096     0.006765627     -0.013531253818361       -1.99999997315267          0.001      
             38      -0.00883430728825634     0.008834307     -0.0176686142882563      -2.0000000326292           0.001      
             39      -0.0110710580870874      0.011071058     -0.0221421160870874      -2.00000000786623          0.001      
             40      -0.0136638180606867      0.013663818     -0.0273276360606867      -2.00000000444142          0.001      
             41      -0.0164779929983223      0.016477993     -0.0329559859983223      -1.99999999989819          0.001      
             42      -0.0198617790133211      0.019861779     -0.0397235580133211      -2.00000000067069          0.001      
             43      -0.0183842079438225      0.018384208     -0.0367684159438225      -1.99999999694425          0.001      
             44      -0.00820642596506204     0.008206426     -0.016412851965062       -1.99999999574261          0.001      
             45      -0.0111181003409486      0.0111181       -0.0222362003409486      -2.00000003066608          0.001      
             46      -0.0151693577848328      0.015169358     -0.0303387157848328      -1.99999998581567          0.001      
             47      -0.0190479368817326      0.019047937     -0.0380958738817326      -1.99999999379107          0.001      
             48      -0.0239555725950801      0.023955573     -0.0479111455950801      -1.99999998309705          0.001      
             49      -0.0272588003963284      0.0272588       -0.0545176003963284      -2.00000001453947          0.001      
             50      -0.0225127037982987      0.022512704     -0.0450254077982987      -1.99999999104056          0.001      
             51      -0.0186421827867802      0.018642183     -0.0372843657867802      -1.99999998856251          0.001      
    
    Actual Value:
        1x500 double
    Expected Value:
        1x500 double

@hivanov-nrel, the sign appears to be flipped here:

% phase delay should be positive number
phase = -unwrap(angle(RAO));

Should the calculation be phase = unwrap(angle(RAO)); which would produce positive values? When I remove the negative sign the tests pass.

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions