Skip to content

Allow for a separate random seed for wind turbulence#1253

Merged
bcoconni merged 5 commits intoJSBSim-Team:masterfrom
seanmcleod70:WindRandomSeed
Apr 8, 2025
Merged

Allow for a separate random seed for wind turbulence#1253
bcoconni merged 5 commits intoJSBSim-Team:masterfrom
seanmcleod70:WindRandomSeed

Conversation

@seanmcleod70
Copy link
Contributor

As per the discussion at #1250 allow the user to specify a separate random seed for the random number generator used by the turbulence code in FGWinds.

I've tested this by running JSBSim.exe with a script and varying the random seeds and comparing the wind output in the CSV file.

So in this example, running the script twice and toggling ``simulation/randomseedbetween 1 and 2 but keepingatmosphere/randomseed` constant gives the exact same wind output with turbulence enabled.

  <run start="0" end="15" dt="0.008333">

	  <property value="1"> simulation/randomseed </property>
	  <property value="3"> atmosphere/randomseed </property>

As mentioned here - #1250 (comment) I haven't been able to write a python test case using the test setup we have.

@codecov
Copy link

codecov bot commented Apr 6, 2025

Codecov Report

Attention: Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 24.95%. Comparing base (e1ea4e8) to head (e228d90).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/models/atmosphere/FGWinds.cpp 60.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1253      +/-   ##
==========================================
+ Coverage   24.77%   24.95%   +0.17%     
==========================================
  Files         169      169              
  Lines       19421    19523     +102     
==========================================
+ Hits         4812     4871      +59     
- Misses      14609    14652      +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@bcoconni bcoconni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! It's good to have you back on board @seanmcleod70 👍

I have suggested one change to GetRandomSeed to cover the corner case where FGFDMExec and FGWinds are using the same random number generator in which case FGWinds::GetRandomSeed must return the same value than FGFDMExec::Srand.

@bcoconni
Copy link
Member

bcoconni commented Apr 7, 2025

I guess you should also add a test case to TestTurbulenceRandomSeed.py to check that the properties atmosphere/randomseed and simulation/randomseed are returning the same value as long as atmosphere/randomseed is not modified.

@seanmcleod70
Copy link
Contributor Author

I've pushed a commit to return FGFDMExec's random seed if one hasn't been assigned to FGWind and also an additional test for this.

@bcoconni bcoconni merged commit 3c2b00d into JSBSim-Team:master Apr 8, 2025
29 checks passed
@bcoconni
Copy link
Member

bcoconni commented Apr 8, 2025

Bonus point: this PR is partially addressing #666 by removing some static variables 👍

@bcoconni bcoconni mentioned this pull request Apr 13, 2025
bcoconni pushed a commit to bcoconni/jsbsim that referenced this pull request May 2, 2025
Co-authored-by: Sean McLeod <sean@seanmcleod.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants