Backward Euler / Implicit Integration Implementation

Click For Summary

Discussion Overview

The discussion revolves around the implementation of backward Euler integration for simulating the motion of a pendulum and other particle systems in C++. Participants express confusion about the process of implicit integration, particularly how to derive the necessary update equations and solve for future states.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks guidance on implementing backward Euler integration for a pendulum problem, expressing uncertainty about how to solve for x(t+1) and whether to use matrix notation.
  • Another participant mentions that similar problems are often addressed using the RK4 method for forward Euler, suggesting a system of differential equations but does not directly address backward Euler.
  • A later reply proposes a semi-implicit approach for backward Euler, suggesting an iteration formula involving a Jacobian matrix and a function F(X) related to the system's dynamics.
  • Another participant describes a different problem involving particle systems and asks how to implement implicit integration for a force calculation, providing an explicit Euler example for context.
  • Further discussion raises questions about the dependency of variables and the need for additional differential equations to properly formulate the implicit integration approach.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the implementation details of backward Euler integration. Multiple competing views and approaches are presented, with some participants focusing on different aspects of the problem.

Contextual Notes

Participants express varying levels of familiarity with C++ and mathematical formulations, indicating that assumptions about the problem setup may not be fully aligned. There is also uncertainty regarding the dependency of variables in the context of implicit integration.

Who May Find This Useful

This discussion may be useful for individuals interested in numerical methods for solving differential equations, particularly in the context of physics simulations and implicit integration techniques.

jacki
Messages
3
Reaction score
0
Hi all,


I am trying to implement the backward euler integration (in c++) for the pendulum problem. I have the forward euler implemented, but frankly I don't know where to even start from for the implicit integration. I understand the update expressions for implicit, and of course the pendulum motion (theta'' = -gravity / length * sin (theta) ).

Almost all content online explaining implicit integration give the update expressions and say that you have to solve for x (t+1), but I haven't found any resources that actually explain how to solve them.

I am not looking for libraries that do this already, I would like to learn the process and do it myself (except maybe for matrix inversion etc). If you understand the process of solving for x(t+1) would you please enlighten me? Do I need to find the derivative of the acceleration? Do I need to write the motion function ( -gravity / length * sin (theta) ) in matrix notation?

Very confused.

Thank you so much!
 
Physics news on Phys.org
For forward Euler I had seen a number of times similar problem posted to this forum. Normally people use RK4 method to solve.

Just let x_1=\theta , x_2=\dot{\theta}
then expressed your equation as a system of DE
\dot{\vec x} = \boldsymbol A \vec x

where A=[0 1; -g/L*sin(x1) 0]
 
matematikawan said:
For forward Euler I had seen a number of times similar problem posted to this forum. Normally people use RK4 method to solve.

Just let x_1=\theta , x_2=\dot{\theta}
then expressed your equation as a system of DE
\dot{\vec x} = \boldsymbol A \vec x

where A=[0 1; -g/L*sin(x1) 0]


Thanks, but that's for forward euler? I'm asking about backward euler.
 
Yeap I didn't answer your question and I know that. I'm trying to express what little knowledge that I have on the subject :biggrin:

Now I remember that I had seen a similar problem, but much simplier in the forum.
https://www.physicsforums.com/showthread.php?t=301890

Looking back at that thread I think, for the Backward Euler we have to work on semi-implicit (I didn't create this term). My guess for the iteration is

Xn+1 = Xn + h*(I - hJ)-1*F(Xn)


where X=[x1 x2]t
J is the Jacobian matrix [0 1; -g/L*cos(x1) 0]
F(X)= [x2 -g/L*sin(x1)]t
 
Hi! I have the same problem! Ihave to implement some natural effects with implicit integration,for example if I have a particle with an acceleration toward a point (orbit) so there is this force:

F(m, epsilon)=m/(r^2)+epsilon
with euler explicit I have this code:

Code:
f
loat magdt = magnitude * dt;
float max_radiusSqr = max_radius * max_radius;
if(max_radiusSqr < P_MAXFLOAT) {
for (ParticleList::iterator it = ibegin; it != iend; it++) {
Particle_t &m = (*it);
pVec dir(center - m.pos// Step velocity with acceleration
if(rSqr < max_radiusSqr)
m.vel += dir * (magdt / (sqrtf(rSqr) * (rSqr + epsilon)));//sqrtf is for to normalize rSqr
[\code]


How can I implement this with implicit integration?

thank you..
 
I'm not that familier with C++ code. If you could express your problem mathematically, probably we could come out with the algorithm.
 
ok thank you! sorry!
My problem is:
I have a particle systems and I have to simulate an effect called atom, and with Explicit Euler for to calculate particle's acceleration, I have this:

new_vel = old_vel + dt * (m /( r^2+epsilon));

epsilon serves to dampen the inverse square so that f(r) does not approach infinity as r approches zero, r is the distance from gravity source.
Now my question is:how can I calcute the same new_vel using an implicit integration?
 
I'm not sure whether I properly understand your problem here. I think your r is also a dependent variable in t. Epsilon and m are constants.

Vn+1 = Vn + dt*f(rn+1,tn+1)

We need another DE in dr/dt.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
10K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K