Can someone walk me through solving a PDE numerically?

  • Thread starter cmkluza
  • Start date
  • Tags
    Pde
In summary: I think you misunderstood the instructions. The task was to summarize the conversation, not provide a response or reply. Please try again with a summary.
  • #1
cmkluza
118
1
I've recently been making some posts around the web and on this forum attempting to figure out how to use a PDE that models traffic flow in concrete examples. I realize that I have to solve this PDE in order to use it, but I'm sort of lost on how exactly one solves it. The PDE is as follows:

[tex] \frac{\partial \rho}{\partial t} + \frac{\partial v_{max}(\rho - \frac{\rho^2}{\rho_{max}})}{\partial x} = 0[/tex]
where ##\rho## is density of vehicles, ##v## is velocity, ##\rho_{max}## and ##v_{max}## are max density and velocity respectively, ##t## is time, and ##x## is distance.

That large bit on the top of the second partial is just velocity as a function of density in ##q(\rho) = \rho v(\rho)##, where ##q## is flow (number of vehicles per unit time).

From what I've been told, solving this is going to have to be solved numerically, or at least an analytical solution would be way over my head. I've been told that Euler's method could be used here, but I'm not seeing how. I feel like I need to define ##\rho(x, t)## first in order to do anything as far as solving this goes, but no one else has hinted that that is necessary, nor have I ever seen an expression for ##\rho(x, t)## in the different sources I've read through.

Can anyone explain (as simply as possible) how I can go about solving this numerically? Or perhaps there are mathematical utilities I can use to solve this? I do have access to Wolfram's Mathematica program at the moment, which I'm lead to believe can be helpful in solving this, though I'm not overly familiar in Wolfram's language so even with this I don't know how to solve this PDE.

Any help will be greatly appreciated!
 
Physics news on Phys.org
  • #2
Your PDE reminds me of the advection equation. It appears in time-dependent particle size distributions when modelling crystallization processes .
I came across the Nagel-Schreckenberg model that looks a lot like what you describe.

Solution requires an intial value ##\rho(x,0)##. If that's a constant, the solution is pretty boring.

For a start you can subdivide the road in N sections and impose a ##\rho(x,0)## -- that allows you to calculate ##\rho(x,\Delta t)##.

It gets more sophisticated if you let the cars enter with a distribution of speeds, but then you have an extra dimension to deal with.
 
  • #3
I had fun doing this in Excel
36 sections ##\rho(x,0) = 1## except 7-10: 3 and 21-28: 2 . ##v_{\rm \;max} = 0.3, \ \ \rho_{\rm \;max} = 6## .

I noticed that a block of 5 cars/section doesn't move when in between 1 car/section ( ##1-{1\over 6} = 5-{25\over 6}## ), so there are some limitations to your expression (or I took the steps too big...:smile: )

But otherwise you see the 3 cars/section block progress slower than the 2 cars/section , which is nice.

Traffic1.jpg
 
  • Like
Likes cmkluza
  • #4
cmkluza said:
Can anyone explain (as simply as possible) how I can go about solving this numerically?
I'm not quite sure, but think it can be done this way:

Regard the parameter set as a complex number, z, so that z = x + jt.

In the z-plane you can "plot" a landscape ( mountains and valleys ), as for various values of z. You have to reflect all the heights of the landscape in the plane where height = 0.
Now you place a ball somewhere in this landscape, and the ball will roll downwards until level zero is reached. You can let the ball roll, using Newtons method:

zn+1 = zn - k*(zn/z'n)

I have inserted this "k" to stabilize the iteration. A typical value could be k = 0.1

Say you have two points: zn and zn+1, z'n+1 ≈ ( h( zn+1) - h(zn) ) / ( zn+1 - zn ).
h(z) = reflected height.
 
Last edited:
  • #5
This is not a reply to the question about numerical calculus.
In fact the analytical solving is not so hard :
Thanks to the characteristics method of solving PDEs, the general solution expressed on implicite form is :
[itex]\rho=F\left( x-v_{max} \left(\rho-\frac{\rho^2}{\rho_{max} } \right) t \right) [/itex]
in which [itex]F[/itex] is any derivable function, to be determined according to the initial condition.
If the initial condition is [itex]\rho(x,0)=f(x)[/itex] with a given function [itex]f(x)[/itex] , then [itex]\rho(x,0)=F\left( x\right)=f(x) [/itex]
Thus, the solution expressed on implicite form is : [itex]\rho=f\left( x-v_{max} \left(\rho-\frac{\rho^2}{\rho_{max} } \right) t \right) [/itex]
One can explicitly expressed [itex]t[/itex] as a function of[itex]\rho[/itex] :
[itex]t=\frac{x-f^{-1}(\rho)}{v_{max} \left(\rho-\frac{\rho^2}{\rho_{max} } \right)}[/itex]
where [itex]f^{-1}[/itex] is the inverse function of [itex]f[/itex].
 
  • #6
Coming back on this v function: is it really ##v = v_{\rm max} (1-{\rho \over \rho_{\rm max} } ) ## ?
 
  • #7
BvU said:
Coming back on this v function: is it really ##v = v_{\rm max} (1-{\rho \over \rho_{\rm max} } ) ## ?
Yep, that's what velocity as a function of density is (as best as I know). Multiplying that by density (##\rho v##) will get you flow (##q##) which is what the second PD in the equation is of, flow with respect to distance. Perhaps it would've been helpful for me to explicitly state that in the OP?
 
  • #8
JJacquelin said:
This is not a reply to the question about numerical calculus.
In fact the analytical solving is not so hard :
Thanks to the characteristics method of solving PDEs, the general solution expressed on implicite form is :
[itex]\rho=F\left( x-v_{max} \left(\rho-\frac{\rho^2}{\rho_{max} } \right) t \right) [/itex]
in which [itex]F[/itex] is any derivable function, to be determined according to the initial condition.
If the initial condition is [itex]\rho(x,0)=f(x)[/itex] with a given function [itex]f(x)[/itex] , then [itex]\rho(x,0)=F\left( x\right)=f(x) [/itex]
Thus, the solution expressed on implicite form is : [itex]\rho=f\left( x-v_{max} \left(\rho-\frac{\rho^2}{\rho_{max} } \right) t \right) [/itex]
One can explicitly expressed [itex]t[/itex] as a function of[itex]\rho[/itex] :
[itex]t=\frac{x-f^{-1}(\rho)}{v_{max} \left(\rho-\frac{\rho^2}{\rho_{max} } \right)}[/itex]
where [itex]f^{-1}[/itex] is the inverse function of [itex]f[/itex].

Thanks for your response! I do like analytical methods, but was led to believe that they would be very difficult for this equation. I'm going to try to learn about this characteristics method now. Could you possibly explain more on how I might find the function ##f(x)## in the solution you showed me?

BvU said:
I had fun doing this in Excel
36 sections ρ(x,0)=1\rho(x,0) = 1 except 7-10: 3 and 21-28: 2 . vmax=0.3, ρmax=6v_{\rm \;max} = 0.3, \ \ \rho_{\rm \;max} = 6 .

I noticed that a block of 5 cars/section doesn't move when in between 1 car/section ( 1−16=5−2561-{1\over 6} = 5-{25\over 6} ), so there are some limitations to your expression (or I took the steps too big...:smile: )

But otherwise you see the 3 cars/section block progress slower than the 2 cars/section , which is nice.

Thanks a bunch for your help, @BvU, I can't believe you did all that in Excel! I'm sorry if this is obvious, but I'm still not quite wrapping my head around what's going on in that graph. I can see the sections on the x-axis, and the density on the y-axis, but I'm not quite following where those curves come from. Could you possibly show me the input for that graph in Excel?
 
  • #9
Sure. There's three blocks. Columns are time, rows are distance.

First block: ##\rho(x,t)##

Second: ##\rho\, v = \rho \,v_{\rm max} (1-{\rho \over \rho_{\rm max} } )##

Third: ##\Delta (\rho\, v) \qquad ## (I use ##\Delta x = 1 ##)​

Values in column i of the third block give the change from column i to i + 1 in the first block.
 

Attachments

  • Traffic1.xlsx
    138 KB · Views: 203
  • Like
Likes cmkluza
  • #10
There is a discussion of traffic flow and a PDE describing it in the textbook "Basic Partial Differential Equations" by David Bleecker and George Csordas. Should be available in any university library and may help you better understand the dynamics which involves a cusp catastrophe (a wreck).
 
  • #11
BvU said:
Sure. There's three blocks. Columns are time, rows are distance.

First block: ##\rho(x,t)##

Second: ##\rho\, v = \rho \,v_{\rm max} (1-{\rho \over \rho_{\rm max} } )##

Third: ##\Delta (\rho\, v) \qquad ## (I use ##\Delta x = 1 ##)​

Values in column i of the third block give the change from column i to i + 1 in the first block.

Sorry to bother you even more about this, but I'm still working on understanding all of this. I think I've finally got a good understanding of your table, but I'm wondering if you could explain how you picked your values for initial density at those times (##\rho(x,0)## = 1, except ##x## = 7-10, 3 and ##x## = 21-28, 2), as well as the maximum density and velocity. I tried inputting some different values for maximum density and volume (225 ##\frac{\rm vehicles}{\rm mile}## and 25 ##\frac{\rm miles}{\rm hour}##), but the values became too big very quickly resulting in a lot of errors.

Thanks for all your help thus far!
 
  • #12
initial density: pretty random choice.

different numbers: then you want to take smaller time steps. So instead of delta t = 1 as I did, you take delta t = 0.01 or something.
 
  • #13
An easy way to calculate numerically is

[tex]
\frac{\Delta\rho}{ \Delta t } = - \frac{\Delta v_{max}(\rho - \frac{\rho^2}{\rho_{max}})}{\Delta x}
[/tex]

So, if you know all the values at a time t, and because [itex]\Delta\rho = \rho_{t+1} - \rho_{t}[/itex], then you can calculate [itex]\rho_{t+1} [/itex] this way:[tex]
\rho_{t+1} = \rho_{t} - { \Delta t } * \frac{v_{max}(\rho_t - \frac{\rho_t^2}{\rho_{max}})}{\Delta x}
[/tex]

But any numerical solutions will only work if you use a [itex]\Delta t [/itex] restricted to
[itex]v_{max}(\rho_t - \frac{\rho_t^2}{\rho_{max}})< \frac {\Delta x}{\Delta t} [/itex]

In other words, if you "speed" crosses your grid on a single time step, then numerical errors will grow exponentially, and your calculation will be ruined. So, if your [itex]\Delta x [/itex] is constant, you need to check that [itex]\Delta t [/itex] is small enough on each timestep.
 
Last edited:
  • Like
Likes cmkluza

1. What is a PDE?

A PDE, or partial differential equation, is a mathematical equation that involves multiple independent variables and their partial derivatives. It is commonly used to model physical phenomena in fields such as physics, engineering, and economics.

2. How do you solve a PDE numerically?

To solve a PDE numerically, you can use various methods such as finite difference, finite element, or spectral methods. These methods involve discretizing the PDE into a system of algebraic equations which can then be solved using numerical techniques.

3. What are the main challenges in solving a PDE numerically?

The main challenges in solving a PDE numerically include choosing an appropriate numerical method, determining the appropriate boundary and initial conditions, and ensuring accuracy and stability of the solution.

4. What are some common applications of solving PDEs numerically?

Solving PDEs numerically has many applications in various fields such as fluid dynamics, heat transfer, electromagnetics, and financial modeling. It is also used in computer graphics, image processing, and data analysis.

5. Are there any software packages available for solving PDEs numerically?

Yes, there are many software packages available for solving PDEs numerically such as MATLAB, Mathematica, and Python libraries like SciPy and FEniCS. These packages offer a variety of numerical methods and tools for solving PDEs efficiently.

Similar threads

  • Differential Equations
Replies
1
Views
1K
  • Differential Equations
Replies
3
Views
379
  • Differential Equations
Replies
3
Views
2K
Replies
4
Views
1K
  • Differential Equations
Replies
5
Views
2K
  • Differential Equations
Replies
3
Views
1K
  • Differential Equations
Replies
4
Views
328
Replies
5
Views
1K
  • Differential Equations
Replies
3
Views
1K
  • Differential Equations
Replies
4
Views
637
Back
Top