Skip to content

Commit

Permalink
Update floating test to better handle near zero test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoor committed Oct 17, 2024
1 parent 974c119 commit 2998c38
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions test/testfloating.jl
Original file line number Diff line number Diff line change
Expand Up @@ -390,30 +390,42 @@ mooring_forces_UNIT = DelimitedFiles.readdlm("$path/data/UNIT_TEST_cct2_FMooring
tt_disps_UNIT = DelimitedFiles.readdlm("$path/data/UNIT_TEST_cct2_tt_disps.csv", ',')
FReaction_UNIT = DelimitedFiles.readdlm("$path/data/UNIT_TEST_cct2_FReactionHist.csv", ',')

mytol = 1e-5
mytol = 1e-4

for iel = 1:length(ptfm_disps_UNIT) #note, purposely iterating over multidimensional array with a single for loop
@test isapprox(ptfm_disps_UNIT[iel],ptfm_disps[iel];atol=max(abs(ptfm_disps_UNIT[iel])*mytol,1e-6))
if abs(ptfm_disps_UNIT[iel])>mytol
@test isapprox(ptfm_disps_UNIT[iel],ptfm_disps[iel];atol=max(abs(ptfm_disps_UNIT[iel])*mytol,1e-6))
end
end

for iel = 1:length(ptfm_forces_UNIT) #note, purposely iterating over multidimensional array with a single for loop
@test isapprox(ptfm_forces_UNIT[iel],ptfm_forces[iel];atol=max(abs(ptfm_forces_UNIT[iel])*mytol,1e-6))
if abs(ptfm_disps_UNIT[iel])>mytol
@test isapprox(ptfm_forces_UNIT[iel],ptfm_forces[iel];atol=max(abs(ptfm_forces_UNIT[iel])*mytol,1e-6))
end
end

for iel = 1:length(hydro_forces_UNIT) #note, purposely iterating over multidimensional array with a single for loop
@test isapprox(hydro_forces_UNIT[iel],hydro_forces[iel];atol=max(abs(hydro_forces_UNIT[iel])*mytol,1e-6))
if abs(ptfm_disps_UNIT[iel])>mytol
@test isapprox(hydro_forces_UNIT[iel],hydro_forces[iel];atol=max(abs(hydro_forces_UNIT[iel])*mytol,1e-6))
end
end

for iel = 1:length(mooring_forces_UNIT) #note, purposely iterating over multidimensional array with a single for loop
@test isapprox(mooring_forces_UNIT[iel],mooring_forces[iel];atol=max(abs(mooring_forces_UNIT[iel])*mytol,1e-6))
if abs(ptfm_disps_UNIT[iel])>mytol
@test isapprox(mooring_forces_UNIT[iel],mooring_forces[iel];atol=max(abs(mooring_forces_UNIT[iel])*mytol,1e-6))
end
end

for iel = 1:length(tt_disps_UNIT) #note, purposely iterating over multidimensional array with a single for loop
@test isapprox(tt_disps_UNIT[iel],tt_disps[iel];atol=max(abs(tt_disps_UNIT[iel])*mytol,1e-6))
if abs(ptfm_disps_UNIT[iel])>mytol
@test isapprox(tt_disps_UNIT[iel],tt_disps[iel];atol=max(abs(tt_disps_UNIT[iel])*mytol,1e-6))
end
end

for iel = 1:length(FReaction_UNIT) #note, purposely iterating over multidimensional array with a single for loop
@test isapprox(FReaction_UNIT[iel],FReaction[iel];atol=max(abs(FReaction_UNIT[iel])*mytol,1e-6))
if abs(ptfm_disps_UNIT[iel])>mytol
@test isapprox(FReaction_UNIT[iel],FReaction[iel];atol=max(abs(FReaction_UNIT[iel])*mytol,1e-6))
end
end


Expand Down

0 comments on commit 2998c38

Please sign in to comment.