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

Fixed incorrect surface moment derivatives and added a moment output to the component #449

Merged
merged 12 commits into from
Dec 18, 2024
Prev Previous commit
Next Next commit
Restore complex step tests. Fix incorrect S_ref derivative accumulati…
…on for non wing surfaces
sabakhshi committed Dec 11, 2024
commit c23073a0840cc07276cde46d2cea2d25f803e155
4 changes: 3 additions & 1 deletion openaerostruct/functionals/moment_coefficient.py
Original file line number Diff line number Diff line change
@@ -121,6 +121,8 @@ def compute(self, inputs, outputs):

# Output the moment vector
outputs["M"] = M
if not self.under_complex_step:
sabakhshi marked this conversation as resolved.
Show resolved Hide resolved
print(M)

# Compute the normalized CM
outputs["CM"] = M / (0.5 * inputs["rho"] * inputs["v"] ** 2 * inputs["S_ref_total"] * self.MAC_wing)
@@ -322,4 +324,4 @@ def compute_partials(self, inputs, partials):
partials["CM", base_name + "_widths"] -= np.outer(M_j * term, base_dMAC_dw)
# partials["CM", base_name + "_S_ref"] -= np.outer(M_j, base_dMAC_dS * term)
partials["CM", base_name + "_S_ref"] += np.outer(M_j * fact, (-1 / S_ref_total + 1 / S_ref_wing))
partials["CM", name + "_S_ref"] = np.outer(M_j * fact, (-1 / S_ref_total))
# partials["CM", name + "_S_ref"] = np.outer(M_j * fact, (-1 / S_ref_total))
4 changes: 2 additions & 2 deletions tests/functionals_tests/test_moment_coefficient.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ def test(self):

comp = MomentCoefficient(surfaces=surfaces)

run_test(self, comp)
run_test(self, comp, complex_flag=True, method="cs")

# This is known to have some issues for sufficiently small values of S_ref_total
# There is probably a derivative bug somewhere in the moment_coefficient.py calcs
@@ -36,7 +36,7 @@ def test2(self):

group.connect("indep_var_comp.S_ref_total", "moment_calc.S_ref_total")

run_test(self, group)
run_test(self, group, complex_flag=True, method="cs")


if __name__ == "__main__":