Conversation
A-CGray
left a comment
There was a problem hiding this comment.
Thanks for these fixes @SichengHe , can you please update your tests to use ADflow's existing RegTest class. See this file for an example.
Also, which version of Tapenade did you use to generate the new derivative code? I think the failing Tapenade check is probably due to a version mismatch, the test uses 3.16
There was a problem hiding this comment.
Please put this file in the reg_tests directory
| # Add the test directory to path for reg_default_options | ||
| sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "reg_tests")) |
There was a problem hiding this comment.
Shouldn't need this once file is moved
There was a problem hiding this comment.
should be all good now.
Thanks for all the feedback! They are very helpful.
sanjan98
left a comment
There was a problem hiding this comment.
Time spectral adjoint fixed.
Moves #endif before case(timeSpectral)
#ifdef guards
A-CGray
left a comment
There was a problem hiding this comment.
I combined the test file you added with the existing time spectral test because all of the setup code was the same.
In the PR summary you say:
Three tests are performed:
- Dot product test (forward vs backward consistency): relative error = 1.06e-15 (machine precision)
- Forward AD vs finite difference: residual derivative relative error = 4.03e-05; function derivatives (cl, cd, cmz) match to 1e-7 — 1e-8
However, I don't see anything in the new time spectral tests that check these
| "Eval Functions Sens:": { | ||
| "64A010pitchingTS_cd": {}, | ||
| "64A010pitchingTS_cl": {}, | ||
| "64A010pitchingTS_cmz": {} | ||
| }, |
There was a problem hiding this comment.
No derivatives are being computed because you don't have any DVs defined
Purpose
Fix the time spectral (TS) adjoint, which was completely broken because the
case (timeSpectral)block ininitres_block(src/solver/residuals.F90) was wrapped inside#ifndef USE_TAPENADE, so Tapenade never generated adjoint code for the spectral time derivative terms. The generated AD code only handledcase (steady), completely missing the TS contributions.Changes:
case (timeSpectral)inresiduals.F90to Tapenade by moving the#endifboundary, with#ifdef USE_TAPENADEblocks to replace pointer access with directflowDomsarray access (required since Tapenade cannot differentiate through Fortran pointers)residuals_b.f90residuals_d.f90residuals_fast_b.f90tests/test_ts_adjoint.pyfor verificationExpected time until merged
Non-urgent. A week or two is fine.
Type of change
Testing
Run with 2 MPI ranks on the NACA 64A010 Euler time spectral case (3 time intervals, pitching oscillation):
mpirun -np 2 python tests/test_ts_adjoint.py
Three tests are performed:
evalFunctionsSens): all three adjoint solves (cd, cl, cmz) convergeChecklist
ruff checkandruff formatto make sure the Python code adheres to PEP-8 and is consistently formattedfprettifyor C/C++ code withclang-formatas applicable