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

Atmospheric flight fix #4946

Merged
merged 5 commits into from
Aug 29, 2020
Merged

Atmospheric flight fix #4946

merged 5 commits into from
Aug 29, 2020

Conversation

starling13
Copy link
Contributor

Fix the error in calculation of drag force basis components.

Leads to reduction of the overall drag on significant angles of attack, as can be seen from the first look.

@impaktor impaktor changed the title Atmospheric flight Atmospheric flight fix Aug 25, 2020
@impaktor
Copy link
Member

Cool.

FYI: "fix" commits aught to be squashed into the correct commit, as we (usually) don't want to track bug fixes in the PR itself.

Looks like there are some clang format issues still. (see wiki dev section on how to run clang-format script)

@fluffyfreak looks like appveyor is working again? I hadn't noticed until now.

@starling13
Copy link
Contributor Author

Ok, I should read the dev wiki parts. Can somebody explain, how to
squash commits into one? Or I must create new branch with correct commit sequence?

@impaktor
Copy link
Member

impaktor commented Aug 25, 2020

https://pioneerwiki.com/wiki/Using_git_and_GitHub#Fixing.2FUpdating_your_pull_request

If you need further help, come by IRC (you need to register a nick with nickserv to speak)

@The-EG
Copy link
Contributor

The-EG commented Aug 25, 2020

Does this address #4847 ?

@starling13
Copy link
Contributor Author

starling13 commented Aug 25, 2020

Does this address #4847 ?

No, It only fix calculation of the linear drag, not angular.
The change was discussed at the bottom part of #4556 conversation.

@WKFO
Copy link
Contributor

WKFO commented Aug 25, 2020

Wait, this does NOT square the local velocity and take its x, y, z components, right? Shouldn't we separate x, y, z first and square each axis individually?

@starling13
Copy link
Contributor Author

starling13 commented Aug 25, 2020

Wait, this does NOT square the local velocity and take its x, y, z components, right? Shouldn't we separate x, y, z first and square each axis individually?

But the operator *, overloaded for vector3d simply multiplies each component of the facteurs.
So after

const vector3d lv2(localVel * localVel);

lv2 contains squares of localVel coordinates.

@WKFO
Copy link
Contributor

WKFO commented Aug 25, 2020

Oh, that's okay then. I was thinking in scalar values in my head, dumb me....

@sturnclaw
Copy link
Member

I'll have to double-check both the original calculation and this one - the way it was originally done, the drag calculation was also responsible for about half of the lift (up to a certain point), which might be the reason the current one doesn't look entirely correct. I'll review this when I get some time over the next few days (I promise!), but if this calculation brings us closer to correct behavior I think it'll be good for merge.

@starling13
Copy link
Contributor Author

I also found a possible bug with Planet::GetAtmosphericState.
The atmosphere temperature rises with altitude.
It is caused by the not so intuitive negative "g" value, computed in Init method:

// surface gravity = -G*M/planet radius^2
m_surfaceGravity_g = -G * sbody->GetMass() / (sbody->GetRadius() * sbody->GetRadius());

which gives positive laps rate in GetAtmospheric state:

const double lapseRate_L = -m_surfaceGravity_g / specificHeatCp; // negative deg/m

I propose to make "g" value positive and make a few corrections of sign in Planet class.
After I'v corrected this error I can see a funny heating while descending from the Earth orbit at 7 km/s.

Is it worth to open an issue and pull request, or I can place the commits in this branch, because I think of computing Mach number, using the atmosphere temperature, which will affect Atmospheric drag?

@impaktor
Copy link
Member

Is it worth to open an issue and pull request, or I can place the commits in this branch

If it's a bug in master related to atmosphere-stuff/similar code, I'm fine with adding commits to this PR.

@The-EG
Copy link
Contributor

The-EG commented Aug 27, 2020

I also found a possible bug with Planet::GetAtmosphericState.
The atmosphere temperature rises with altitude.

#4216 and some prior discussion about it in #4219

edit: I'm not informed enough to have an opinion either way, I just thought it helpful to have the prior stuff.

@starling13
Copy link
Contributor Author

#4216 and some prior discussion about it in #4219

What was the result? The long discussion, the consensus about that laps rate troposhere model, being used, takes positive g and LR is negative itself, big diff at pull request, which cleans up the code and insulted author deleted the branch? Or language barrier prevented me from uderstanding.

@The-EG
Copy link
Contributor

The-EG commented Aug 27, 2020

#4216 and some prior discussion about it in #4219

What was the result? The long discussion, the consensus about that laps rate troposhere model, being used, takes positive g and LR is negative itself, big diff at pull request, which cleans up the code and insulted author deleted the branch? Or language barrier prevented me from uderstanding.

I wasn't involved with it back then, but my take on it now is that there was reluctance to just flip the signs and call it good. I wouldn't read too much into everything else, including the branch being deleted. At least, that's not why I was pointing out that PR, only for the discussion about the formulas used.

I think if you have a solution and are willing to back it up and discuss it then it would be a good contribution to make.

@impaktor
Copy link
Member

impaktor commented Aug 27, 2020

In accordance with the "Chesterton's fence"-analogy[*], I'm fine with changes as
long as the author knows why they're doing it (beyond "seems to work"), and
understands the original code. This was what was not properly motivated in the
previous PR, linked above, which is why it ended up on the cutting-room floor.
At least that was my involvement in the issue.

If you guys understand the code, go for it (I haven't looked at it myself).

[*] From G.K. Chesterton, The Thing (1929):

The more modern type of reformer goes gaily up to [a fence] and says, “I
don’t see the use of this; let us clear it away.” To which the more
intelligent type of reformer will do well to answer: “If you don’t see the
use of it, I certainly won’t let you clear it away. Go away and think. Then,
when you can come back and tell me that you do see the use of it, I may
allow you to destroy it.

@starling13
Copy link
Contributor Author

starling13 commented Aug 27, 2020

The results of the correction for venus:
imageup.ru
imageup.ru

P.S. It seems public wiki at bitbucket.org repositories uses temporary image links...

@Zireael07
Copy link

@starling13: Nothing shows?

@starling13
Copy link
Contributor Author

starling13 commented Aug 27, 2020

The final test results, after correction of next error with the signs of "g" and "lapse rate". Both errors make the results incorrect, but realistic.
Corrected density decrease more smooth, and temperature drops with altitude realistically untill tropopause.
Venus:
imageup.ru
imageup.ru
imageup.ru
Earth:
imageup.ru
imageup.ru
imageup.ru
Mars:
imageup.ru
imageup.ru
imageup.ru

@starling13
Copy link
Contributor Author

@Web-eWorks, if you found correction of drag force suitable to merging, decide if it's worth to make also atmospheric parameters fix, discussed above before merging.

@sturnclaw
Copy link
Member

Left a few comments and requests for change - I'd appreciate the atmospheric density changes being added to this PR as (I presume) they're small enough to not be a burden while reviewing!

@starling13
Copy link
Contributor Author

Left a few comments and requests for change - I'd appreciate the atmospheric density changes being added to this PR as (I presume) they're small enough to not be a burden while reviewing!

I made dedicated clang-format commit on Planet.cpp file because it leaves the main atmosphere computations correction commit clear and atomic.

@sturnclaw
Copy link
Member

Left a few comments and requests for change - I'd appreciate the atmospheric density changes being added to this PR as (I presume) they're small enough to not be a burden while reviewing!

I made dedicated clang-format commit on Planet.cpp file because it leaves the main atmosphere computations correction commit clear and atomic.

That's the way we prefer things, thank you! Left one change request, but then I think this PR will be good for merge!

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.

6 participants