Advertisement
Guest User

Untitled

a guest
May 5th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. (* Set Constants *)
  2. n = 1;
  3. [Lambda] = 1;
  4.  
  5. (* Set functions *)
  6. p[r_] = 1/r^2;
  7. q[r_] = 1/r;
  8.  
  9. (* ODE's, which for some reason I called pde1/2 *)
  10. pde1 = D[[Phi][r], {r, 2}] + q[r]*D[[Phi][r], {r, 1}] -
  11. p[r]*(n - [Alpha][r])^2 [Phi][r] + [Lambda]/
  12. 2 (1 - [Phi][r]^2) [Phi][r] == 0
  13. pde2 = D[[Alpha][r], {r, 2}] -
  14. q[r]*D[[Alpha][r], {r, 1}] + (n - [Alpha][r]) [Phi][r]^2 == 0
  15.  
  16. (* Min/max numbers *)
  17. min = 0.000001;
  18. max = 3.4; (* Define a "finite infinity" - I would like to set this higher *)
  19.  
  20. (* Boundary Conditions *)
  21. bc = {[Phi][min] == 0, [Alpha][min] == 0, [Phi][max] ==
  22. 1 - 1/max Exp[-max], [Alpha][max] == 1 - 5/max Exp[-max]};
  23. (* solution[r_]=NDSolve[{pde1,pde2,bc},{[Phi],[Alpha]},{r,min,max},
  24. Method[Rule]{StiffnessSwitching},AccuracyGoal[Rule]5,PrecisionGoal
  25. [Rule]4] *)
  26.  
  27. sol = NDSolve[{pde1, pde2, bc}, {[Phi], [Alpha]}, {r, min, max},
  28. Method -> {"StiffnessSwitching",
  29. Method -> {"ExplicitRungeKutta", Automatic}}, AccuracyGoal -> 15,
  30. PrecisionGoal -> 15, MaxSteps -> 20000]
  31.  
  32. Plot[Evaluate[{[Phi][r], [Alpha][r]} /. sol], {r, 0, 4}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement