Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding random generator seed to all pytacs/mphys tests #302

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/integration_tests/openmdao_analysis_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
assert_check_totals,
)

from tacs import elements
from tacs import TACS

ErrorTuple = namedtuple("ErrorTuple", ["forward", "reverse", "forward_reverse"])
Expand Down Expand Up @@ -58,6 +59,9 @@ def setUp(self):
if self.wrt is None:
self.wrt = []

# Seed random number generator in tacs for consistent test results
elements.SeedRandomGenerator(0)

def setup_problem(self, dtype):
"""
Setup openmdao problem object we will be testing.
Expand Down
4 changes: 4 additions & 0 deletions tests/integration_tests/pytacs_analysis_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
from mpi4py import MPI

from tacs import elements
from tacs import TACS
from tacs import problems
from tacs import constraints
Expand Down Expand Up @@ -63,6 +64,9 @@ def setUp(self):
# Populate fd/cs perturbation vectors based on user-defined method
self.setup_tacs_vecs(self.fea_assembler, self.dv_pert, self.xpts_pert)

# Seed random number generator in tacs for consistent test results
elements.SeedRandomGenerator(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

How does seeding the random generator in elements affect the random generator used by the Eigensolver? Are they the same?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It calls the same C++ seed function srand that should seed all random number functions used in tacs.


def setup_tacs_problems(self, comm):
"""
Setup pytacs object and problems we will be testing.
Expand Down
Loading