reilleya / openMotor

An open-source internal ballistics simulator for rocket motor experimenters
GNU General Public License v3.0
398 stars 78 forks source link

Finocyl Regression Error #108

Closed AstroChuck closed 5 years ago

AstroChuck commented 5 years ago

image The area graph of this finocyl is producing odd results. Note that following the regression curves shows weird behavior near the top fin at about 75% of the y height of the grain. image Clean File with glitchy behavior attached. Preliminary investigation shows this behavior is exists on 5 fin, 8 fin, 11 fin, 13 fin, and 19 fin geometries. The bug persists over different core and grain diameters, as well as over different fin thicknesses and lengths. Changing the web burnout threshold does not affect the issue. Finocyl_Glitch.zip

reilleya commented 5 years ago

Ouch! Was this on master or staging?

AstroChuck commented 5 years ago

Staging

mariohm1311 commented 5 years ago

This is reproducible in master a.k.a. 0.3.0. Additionally, decreasing time step worsens oscillations.

dt = 0.04 s dt = 0.04 s

dt = 0.01 s dt = 0.01 s

mariohm1311 commented 5 years ago

This isn't just limited to Finocyl: star, moon burner, X core, C and D grains have all been tested and found to suffer from the same bug. Moreover, since no artifacts could be seen in their respective regression graphs, I don't think that is related to the problem.

It can also be reproduced for a moon burner grain configuration with 0 offset, which should perform comparably to a BATES grain. Since the difference between those two lies in the regression area calculation method (perforated vs FMM), I suggest starting the search there.

image

image

image

image

image

image

mariohm1311 commented 5 years ago

Increasing grain map dimension reduces the magnitude of the oscillations, so this narrows the problem down to the FMM solver.

Map dimension = 750 image

Map dimension = 1500 image

reilleya commented 5 years ago

Mario is correct, as this issue appears for FMM grains, which includes everything but end burners, BATES, and now rod and tube grains. The issue is that grain mass is calculated by taking the grain's regression image (where pixel value corresponds to regression depth) and summing up the area that exceeds the grain's current regression depth. This leads to grain mass vs regression depth having a lot of steps in it because of the discrete nature of the image. Mass flow is the derivative of that steppy function, so it ends up very chaotic. I tried to do some smoothing to the values (see commit 4cf9419b17f59d532ae1c87b90b6a0f9fd3d15a3) but it seems to have not worked if this still shows up on staging. I will revisit this and try something else to smooth it out. Does anyone have any recommendations for how to smooth out the step function produced by the regression image?

PS: @mariohm1311 I plan to tackle tabular propellant data next. Let me know if you have any suggestions for what you want the UI to look like.

reilleya commented 5 years ago

As a side note, the issue with the contours shown on the regression plot is annoying but purely a visual defect.

mariohm1311 commented 5 years ago

I would suggest running traditional upsampling methods for the regression map such as bilinear or bicubic interpolation, since those are cheap to compute, and see if the result is any better. If not, something slightly more involved such as pixel-shift super-resolution techniques can be applied (a naive implementation isn't that complex).

@reilleya Regarding tabular propellant data, if anything just make sure you accept negative exponents. Burnsim has this feature, yet doesn't accept negative exponents, so :/. Once you have some prototype, please post some pictures on the relevant issue and ping me, so I can give you some suggestions. For now, I'll let you do what's easier for you.

reilleya commented 5 years ago

Well, it still isn't perfect, but I have a decent solution for this pushed to staging. Let me know if you find any configurations that are awful. I will define awful as "resembling any of the examples above other than the last one, which is only kind of bad".