Message Boards Message Boards

Solve Boltzmann eq in 2D with NDSolve and the method of lines in less time?

I tried to solve the Boltzmann equation in 2 spatial dimensions with NDSolve and the method of lines. In the first call of NDSolve in the attached Mathematica notebook the computation time jumps from 3 minutes for MinPoints -> 19 to more than 5 hours for MinPoints -> 20. What is the reason for this? What can I do to limit the computation time?

pde = D[f[t, x, y, kx, ky], 
    t] + (v.Grad[f[t, x, y, kx, ky], {x, y}]) + 
   1/hbar*(F.Grad[f[t, x, y, kx, ky], {kx, ky}]) == 0

ics = {f[0, x, y, kx, ky] == 
   f0[hbar^2*((kx - kxShift)^2 + ky^2)/(2*m), mu, T],
  f[t, -L/2, y, kx, ky] == 
   f0[hbar^2*((kx - kxShift)^2 + ky^2)/(2*m), mu, T],
  f[t, L/2, y, kx, ky] == 
   f0[hbar^2*((kx - kxShift)^2 + ky^2)/(2*m), mu, T],
  f[t, x, -L/2, kx, ky] == 
   f0[hbar^2*((kx - kxShift)^2 + ky^2)/(2*m), mu, T],
  f[t, x, L/2, kx, ky] == 
   f0[hbar^2*((kx - kxShift)^2 + ky^2)/(2*m), mu, T]}

parameters = {hbar -> 1.054588664*10^-34, e -> 1.60218892*10^-19, 
  kB -> 1.380662*10^-23, T -> 300., mu -> 2.348*10^-18, 
  m -> 9.109383*10^-31, kxShift -> 8.0*10^9, xE -> 0, yE -> 0, 
  tau -> 0.3}

borders = {L -> 40.0, kmax -> 4.*10^10}

(sol1 = NDSolve[Union[{pde}, ics] /. parameters /. borders, 
    f, {t, 0, 1}, {x, -L/2, L/2} /. borders, {y, -L/2, L/2} /. 
     borders, {kx, -kmax, kmax} /. borders, {ky, -kmax, kmax} /. 
     borders, 
    Method -> {"MethodOfLines", "TemporalVariable" -> t, 
      "SpatialDiscretization" -> {"TensorProductGrid", 
        "MinPoints" -> 19}}, WorkingPrecision -> MachinePrecision, 
    PrecisionGoal -> 4, AccuracyGoal -> 12]) // AbsoluteTiming
Attachments:
POSTED BY: Ralph Trenkler
2 Replies

When doing a numerical calculation, it's always a good idea to scale your parameters so they are around 1

POSTED BY: Frank Kampas

Yes, exactly. @Ralph Trenkler, how do you think your hbar -> 1.054588664*10^-34 competes with WorkingPrecision -> MachinePrecision ? To add to Frank's comments, you should specify as many parameters as you can in terms of whole not decimal numbers to keep it simple - tracking of precision. Physicist usually do this with physical unit rescaling - going into unit-less space - dividing by hbar - etc. And that would land you approximately in parameter values order of 1.

POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract