Calculating proper ERP and CFM values for your simulation

Post Reply
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Calculating proper ERP and CFM values for your simulation

Post by benelot »

Hi,

Now that I have been pointed out that if you change your simulation timestep to something small (1/240,1/1000 etc.), you probably need to adjust the ERP and CFM to get non-exploding simulations.

So I wanted to do that:

ERP
Error Reduction Parameter, [0;1], The ERP specifies what proportion of the joint error will be fixed during the next simulation step.

From what I think, it should be lower for smaller timesteps, right?
However the ODE documentation (I was pointed to that a lot, http://www.ode.org/ode-latest-userguide.html#sec_3_8_2) says, the calculation is the following:

Code: Select all

yourERP = timeStep * kSpring / (timeStep * kSpring + kDamper)
In simple words, the ERP is independent of the timestep and only dependent on the damper because that is what is going to change the ratio. I understand the damper's influence, as you want slower convergence, the higher the damping constant is. But why is it independent of the timestep? Smaller steps would better reduce errors in smaller steps, right?

Edit: This is wrong, ERP is dependent on the timestep and the timestep is measured as T =1/f where f is the frequency of your update [second^-1].

CFM
Constraint Force Mixing, [0;infty], A nonzero (positive) value of CFM allows the original constraint equation to be violated by an amount proportional to CFM times the restoring force \lambda that is needed to enforce the constraint.

From what I think, this should be higher if you want to get the simulation away from singularities
However the ODE documentation (http://www.ode.org/ode-latest-userguide.html#sec_3_8_2) says, the calculation is the following:

Code: Select all

yourCFM = btScalar(1) / (timeStep * kSpring + kDamper)
In simple words, the CFM is dependent on the timestep, the spring and the damper. Spring and damper influence I understand, because it is exactly what you want. But why is the timestep in the divisor? Do we get higher probability for singularities if we have bigger timesteps? Also the tip to increase the CFM if you want to avoid singularities is not included in this formula (yourCFM <= 1).

What am I getting wrong here?
Last edited by benelot on Thu Dec 31, 2015 10:43 am, edited 1 time in total.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Calculating proper ERP and CFM values for your simulatio

Post by Basroil »

"In simple words, the ERP is independent from the timestep and only dependent on the damper because that is what is going to change the ratio. "

How so? The ERP has a time-step parameter right there doesn't it?

I think you might want to read up on Baumgarte stabilization, and maybe even http://www.osrfoundation.org/wordpress2 ... ar2014.pdf. Erwin also has plenty of information on that in the supplementary presentations (look in the bullet documentation) and here on the forum
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: Calculating proper ERP and CFM values for your simulatio

Post by benelot »

Right, it does have a timestep parameter, so it is not independent,I was wrong in thinking that.

But I find it counterintuitive that the ERP increases with the timestep, because the damper loses influence the higher the timestep is. therefore the ratio

Code: Select all

 timeStep * kSpring / (timeStep * kSpring + kDamper) -> 1 for timestep -> infty
Edit: Wrong, ERP decreases with the timestep, because it is measured in T = 1/f where f is your update frequency [1/second]

I thought it is better to lower the ERP to give each timestep a smaller amount of error to resolve? Is that wrong? With the formula above and a spring and damper of 1, it tries to resolve 0.995851! Or is the timestep not 240 but 1second / 240? That would make sense now that I think of it! And I see that I have already written that above, so I confused myself. Sorry!

Thanks for the resource you sent me, I am going to read about Baumgarte stabilization!
Post Reply