# A Preventing Oscillations w/ Coarse Calculation Increments?

#### Stargazer43

Summary
I'm trying to solve a system of equations, but it exhibits significant oscillatory behavior and difficult convergence if my calculation increments are too large.
I'm trying to solve the following set of equations across several discrete increments. These aren't the exact equations I'm using, but they're a simplified version with the same general structure...it's basically a set of equations describing a transfer rate along a fixed length, where "Z" is the length, and my increment is some fraction of Z. The values of C, D, and X are all between 0 and 1.

A = B*(C - D)
D = (10^6) * X
X = (A*Z)/(10+(A*Z))

The issue I've been running into is this: if the value of B is too large, then it will lead to oscillatory behavior where X will rapidly increase in the first increment beyond what is physically possible, and then in the next increment swing back the other way as the value of D exponentially increases. This is heightened by the fact that in the initial increment, D is typically 0, and C is typically ~1. In the subsequent increments, the product of the two is typically very small (on the order of 0.1 or less), so it's just the initial few increments that cause problems.

If I make my increments infinitely-small, this goes away, but the calculation time becomes unrealistic. If I try to use if/then statements in my calculations to limit the maximum value of "A", the solvers I'm using majorly struggle, since it creates a significant discontinuity.

Are there any numerical stabilization techniques I can use to prevent this calculation from going haywire if the value of "B" is too large? Is there a better way to set up the equations such that it will limit the value of "A" to a maximum and prevent oscillations, without introducing excessive error?

I saw an article from Comsol on a similar problem, but since I'm not using their software and am not well-versed in PDEs I was struggling to recreate their solution on my own.

Related Differential Equations News on Phys.org

#### pbuk

What software are you using and what integration method?

#### Stargazer43

What software are you using and what integration method?
I'm using Aspen Custom Modeler w/ their 1st order BFD method, but I have tried most of their other built-in methods with the same result. I get the same issue when I try to numerically integrate in Excel also, unless I make my increment size extremely small.

#### pbuk

Yes an implicit method is probably the right choice here, you probably want a variable step size to get over the initial stiffness. I'm not familiar with that software but a search gave me this manual and a quick look turned up (p139):

Element spacing is uniform within a given domain section, but non-uniform spacing can be applied using multiple sections, each with a different spacing. The latter is particularly useful for modeling PDE systems with sharp fronts.
Have you tried that?

#### FactChecker

Gold Member
2018 Award
Sophisticated programs will vary the step size at different locations to control any divergence. Unfortunately, I don't know what is currently available for use.

#### RPinPA

Homework Helper
Predictor-corrector methods (the Runge-Kutta algorithm being the classic one) are often the answer to instability in evaluating differential equations. I'm not familiar with your software so don't know that's an option or if there's a good way to graft Runge-Kutta into the solver.

"Preventing Oscillations w/ Coarse Calculation Increments?"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving