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

Lift distribution post-processor #121

Merged
merged 27 commits into from
Jun 10, 2021
Merged

Lift distribution post-processor #121

merged 27 commits into from
Jun 10, 2021

Conversation

sduess
Copy link
Collaborator

@sduess sduess commented Feb 18, 2021

Lift distribution post-processor was failing due to missing adjustments to previous SHARPy changes. The post-processor now reads aerodynamic forces from aero timestep and adjusts the lift force at nodes shared from two different surfaces (e.g. at symmetry plane). Adjusted lift force along with x-,y-, and z-coordinates of leading are exported to txt format for lift distribution evaluations. Code has no impact on any other SHARPy code.

- Lift distribution post-processor caused error since it was not updated to the latest SHARPy changes
- Lift force/ force in z-direction is exported along with x,y, and z coordinates of leading edge and surface id
- correction of lift for nodes who share different surface ids (e.g. symmetry plane)
@sduess sduess requested a review from ArturoMS13 February 18, 2021 10:41
import sharpy.utils.cout_utils as cout
from sharpy.utils.settings import str2bool
from sharpy.utils.solver_interface import solver, BaseSolver
import sharpy.utils.settings as settings
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import sharpy.utils.settings as settings
import sharpy.utils.settings as settings
import sharpy.aero.utils.mapping as mapping


norm = 1.0

tstep = self.data.aero.timestep_info[self.data.ts]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tstep = self.data.aero.timestep_info[self.data.ts]
aero_tstep = self.data.aero.timestep_info[self.data.ts]
struct_tstep = self.data.structure.timestep_info[self.data.ts]

node_counter = 0
for i_surf in range(tstep.n_surf):
n_dim, n_m, n_n = tstep.zeta[i_surf].shape
forces = tstep.forces[i_surf] + tstep.dynamic_forces[i_surf]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
forces = tstep.forces[i_surf] + tstep.dynamic_forces[i_surf]
forces = mapping.aero2struct_force_mapping(
aero_tstep.forces,
self.data.aero.struct2aero_mapping,
aero_tstep.zeta,
structural_tstep.pos,
structural_tstep.psi,
self.data.structure.node_master_elem,
self.data.structure.connectivities,
structural_tstep.cag(),
self.data.aero.aero_dict)
forces += mapping.aero2struct_force_mapping(
aero_tstep.dynamic_forces,
self.data.aero.struct2aero_mapping,
aero_tstep.zeta,
structural_tstep.pos,
structural_tstep.psi,
self.data.structure.node_master_elem,
self.data.structure.connectivities,
structural_tstep.cag(),
self.data.aero.aero_dict)

norm = 1.0

tstep = self.data.aero.timestep_info[self.data.ts]
k_total = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
k_total = 0

k_total += n_n

# get aero forces
lift_distribution = np.zeros((k_total, 5))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
lift_distribution = np.zeros((k_total, 5))
lift_distribution = np.zeros((self.data.structure.num_node, 5))

Comment on lines 68 to 70
node_counter = 0
for i_surf in range(tstep.n_surf):
n_dim, n_m, n_n = tstep.zeta[i_surf].shape
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
node_counter = 0
for i_surf in range(tstep.n_surf):
n_dim, n_m, n_n = tstep.zeta[i_surf].shape

node_counter = 0
for i_surf in range(tstep.n_surf):
n_dim, n_m, n_n = tstep.zeta[i_surf].shape
forces = tstep.forces[i_surf] + tstep.dynamic_forces[i_surf]
abs_forces = np.zeros((n_m, n_n))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
abs_forces = np.zeros((n_m, n_n))
abs_forces = np.zeros((self.data.structure.num_node))

@ArturoMS13
Copy link
Contributor

Hi Stef,
thank you for the very interesting feature.
I have commit some changes to keep the function compatible with any kind of structure that can be created in sharpy.
Can you have a look at it?
Let me know if I forgot something

@ngoiz
Copy link
Contributor

ngoiz commented Feb 18, 2021

Hi all, and nicely done on this first PR, Stef!

One thing I noticed is that the settings for this solver use what was the old convention (self.settings_default etc. as an instance attribute defined in the class' __init__()). To make the story short, back when I did the documentation builder settings defaults/types... need to be in given as class attributes such that they are included in the docs (the tables that appear online are self generated and require this). So if you can move them to class attributes and include the docstring modification line that'd be great (you can check any solver that has docs online to see how it's done).

Then, another thought that comes to mind is whether we'd like to merge this postproc with AeroForcesCalculator. It seems like both are doing the similar things and a lot of code is very similar. I was just updating it the other day to compute moments as well about the A frame (it is in dev_moments) so maybe we can bring all together to make a more comprehensive solver? Thoughts?

@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2021

Codecov Report

Merging #121 (c7c3de8) into develop (affec06) will decrease coverage by 0.03%.
The diff coverage is 33.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #121      +/-   ##
===========================================
- Coverage    62.56%   62.52%   -0.04%     
===========================================
  Files          124      124              
  Lines        22655    22679      +24     
===========================================
+ Hits         14173    14179       +6     
- Misses        8482     8500      +18     
Impacted Files Coverage Δ
sharpy/utils/algebra.py 68.00% <10.00%> (-1.04%) ⬇️
sharpy/postproc/liftdistribution.py 45.83% <37.50%> (-2.45%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update affec06...c7c3de8. Read the comment docs.

@sduess
Copy link
Collaborator Author

sduess commented Apr 22, 2021

Hi guys!
I have updated the lift distribution post-processor. I have adapted some of your suggestions and improved the code. The new setting convention is used now and you can export the lift coefficient for which a panel area calculation was needed and implemented.
For now, I would not merge the postprocessor with the AeroforcesCalculator, as they are highly customized to their respective tasks and not easy to merge.

Let me know what you think!

for inode in range(N_nodes):
if self.data.aero.aero_dict['aero_node'][inode]:
# transform forces from B to A frame
lift_distribution[inode,3]=np.dot(rot.T, forces[inode, :3])[2] # lift force
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I believe this will not always be the lift force. In the case, say the fluid is rotated but the wing is straight (i.e. A and G coincident) you will not be capturing the perpendicular to the free stream.

How @ArturoMS13 implemented this was to find the free stream direction at the section and project the force onto it (this would be the drag), then, the remainder of the force is assumed to be the lift (there would be a side force component particularly near tips but it makes the calculation simpler).

If you have a look at the Polars file you may it is done there if you'd like to implement it

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if I'm not mistaken forces is in B frame. To get them to A you'll need the local CRV to find cab and then you can use rot.T to get them onto G.

This is always so confusing......it's been years for me and still have doubts. I put a little function in algebra called get_transformation() that gets you the projection matrix based on the string you give it.

sharpy/utils/algebra.py Outdated Show resolved Hide resolved
Copy link
Contributor

@ngoiz ngoiz left a comment

Choose a reason for hiding this comment

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

Looking good Stef! I left a few comments on getting the lift but I do agree with you in that it is best keeping this one separate from AeroForcesCalculator.

Let me know if you have any questions about the comments

@ngoiz ngoiz changed the title Dev postproc changes Lift distribution post-processor Apr 28, 2021
Copy link
Contributor

@ArturoMS13 ArturoMS13 left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution!

sharpy/postproc/liftdistribution.py Outdated Show resolved Hide resolved
Co-authored-by: Arturo Muñoz-Simón <[email protected]>
Copy link
Contributor

@ngoiz ngoiz left a comment

Choose a reason for hiding this comment

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

Many thanks!

@sduess sduess merged commit c3b09a0 into develop Jun 10, 2021
@ngoiz ngoiz deleted the dev_postproc_changes branch May 13, 2022 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants