DBooots / KerbalWindTunnel

A mod for Kerbal Space Program to provide atmospheric performance data for spaceplanes and aircraft.
Other
11 stars 3 forks source link

Inaccuracies and inconsistencies in version 1.3.0 #14

Closed FastAndFishious closed 2 years ago

FastAndFishious commented 2 years ago

It seems that version 1.3.0 does not calculate drag and lift correctly, and sometimes completely ignores the root part.

With only the root, everything appears to be normal, the drag matches the in-game value. screenshot7

Adding a part at the front, the drag shoot way up, when it should barely increase. screenshot8

Adding a part at the back has the opposite effect; it's as if the 100's front face was fully shielded, but the drag from the 200 was ignored. screenshot9

Changing the root part seams to inverse the situation: the back of the 200 is shielded, and the 100's drag is ignored. screenshot10

Here is another strange result: by attaching the 100 on the reaction wheel, then making it the root (it is order dependent), it gets totally ignored, even its mass; the pitching torque is practically zero, and it's unaffected by the fuel in the 100. Capture d’écran (76)

I also did some tests with fairings and cargo bays, and with long stacks of fuel tanks, which proved to be even stranger. In contrast, version 1.2.4 passed all of my tests flawlessly.

DBooots commented 2 years ago

This appears to be linked to https://github.com/DBooots/KerbalWindTunnel/issues/12 .

Troubleshooting is in progress to figure out what's going on. If this isn't stock behaviour based on attachment nodes occluding weirdly, I'm guessing it has something to do with https://github.com/DBooots/KerbalWindTunnel/commit/f6abbe57c5493039a760eeb2375aec45255c1fdf .

DBooots commented 2 years ago

Annotating for my own reference: tests pass 1.2.5.-1. There's only four commits between those versions. 5c511fa2f1d3fa00c91c68358942cb1b71ae9b49 checked out correctly. Can probably blame https://github.com/DBooots/KerbalWindTunnel/commit/0b4e6a392424ccc7742618220710e8213f6d4f5d - Confirmed.

DBooots commented 2 years ago

There's still an edge case where re-rooting, removing, and then replacing a part causes it to cycle between 1 or 2 erroneous results and the correct result. This appears to be caused by the order in which parts are cached and their relative placement in the ShipConstruct.parts list. Under the new method, parts are cached in parent-child order instead of the parts list order. I corrected most of the issues by then sorting the cached list by the original indices. There's still something not quite right... but I'm out of debugging time for the weekend.

DBooots commented 2 years ago

Edge cases appear to be resolved, actually. @FastAndFishious I'm going to close this issue with the release of 1.3.1. Please let me know if anything still seems off.

FastAndFishious commented 2 years ago

Are you sure you correctly released version 1.3.1? Because it's stupidly broken. The drag calculation is basically:

  1. Calculate the drag of the last part of the first branch in the tree, ignoring if it’s shielded by a fairing or a cargo bay.
  2. Apply this drag to every unshielded part.
  3. There is no 3, we are done. This is different from version 1.3.0, but obviously still very wrong. On the flipside, the root part issues seam to be fixed, so that’s nice.
DBooots commented 2 years ago

Can you show an example? 1.3.1 passed my standard test craft and I've tried to reproduce the behavior you describe, but simple craft seem to have the drag representative of the correct parts regardless of order.

FastAndFishious commented 2 years ago

Upon closer inspection, it’s actually the drag cube that is pasted to other parts, not the drag.

First, I’ve simplified my Physics.cfg to facilitate the testing (line 140):

DRAG_TIP
{
    key = 0 1 0 0
}
DRAG_SURFACE
{
    key = 0 0 0 0
}
DRAG_TAIL
{
    key = 0 0 0 0
}

Basically, only front drag. Next, we start with a 100. So good so far, 235 kN. screenshot8

After attaching a 200 on the front, the drag exactly doubles to 470 kN, when it should stay the same, because only front drag is applied. screenshot9

Attaching a small nose cone at the back, the drag stays the same. screenshot15

However, turn it 180 and now it’s tripled to 706 kN. This makes sense; the 200’s back face is fully covered, so a back facing part adds no drag. screenshot12

Now, lets consider the nose cone alone. About 1/3 kN for the front face alone. screenshot10

If we go back to our previous setup, but add the cone BEFORE the 200, it becomes the last part of the first branch, so it’s drag cube applies to everyone. And because its back face is covered, it adds no drag, but the two fuel tanks are forwards, so we have 2/3 kN. screenshot13

And when the three parts face forward, we get 1 kN! Science! screenshot14

Results are basically the same with an unmodified Physics.cfg, just more muddied.

DBooots commented 2 years ago

Thanks for researching this bug. I've tracked down the root cause now, and I would never have found it without your feedback. Your screenshots and steps to reproduce are stellar and are a model to all bug reports.