MotorSim 2.0 BETA
I am trying various ways to calculate the volume and surface area of an extruded grain with an arbitrary cross section. This turns into the problem of determining the surface area and perimeter of this cross section respectively.
Using java.awt.geom I can use Flattening path iterator to determine the perimeter of the cross section to a reasonable error. In this method the first and second derivatives of the perimeter function are stable. Determining the area of the cross section is not easy. I tried a Monte Carlo approach, testing points to approximate how much of the bounding rectangle is filled. Unfortunately with this method, and a linear interpolation in between, the first derivative of volume is a stair-step function and the second derivative is degenerate.
Increasing the sampling only increases the frequency.
Changing the burn calculation from using dV/dR to Area * delta-R times fixes the problem. Here the results are stable, but I see the initial ringing from having too large a delta-R. (Actually I suspect that the ringing is caused by too large a simulation step relative to chamber free space)
Reducing the regression step rate cleans it up. There are still artifacts from the poor volume calculations introduced by the surface area of the burning ends (Calculated via cross-section area) and the fact that the volume is used in calculating chamber pressure. Only V(R) not dV/dR is used, so there are no longer instabilities
Searching on the web I found an easy way to calculate the area of an irregular concave polygon. Combining the boolean geometry in java.awt.geom and the method described at http://valis.cs.uiuc.edu/~sariel/research/CG/compgeom/msg00831.html I am able to calculate the area of the grain directly rather than using a statistical approximation (Monte Carlo). I am still approximating the grain as a polygon to do this (via FlatteningPathIterator).