Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #Pkg.add("Decimals") # Not needed because this is on juliabox
  2.  
  3. using Decimals
  4.  
  5. # Defining Variables
  6. Da = Decimal(3e-5)
  7. Db = Decimal(4e-5)
  8. dx = Decimal(0.003)
  9. dt = Decimal(1)
  10. n = Decimal(-0.5)
  11. t = 0
  12.  
  13. phia = Decimal((Da*dt)/(dx*dx))
  14. phib = Decimal((Db*dt)/(dx*dx))
  15.  
  16. cs1 = decimal(0)
  17. cs2 = decimal(1)
  18.  
  19. values = []
  20. column = Dict()
  21.  
  22. # Creating the first column
  23. # while n <= Decimal(0)
  24. # if n == Decimal(0)
  25. # column[string(n)] = .36
  26. # else
  27. # column[string(n)] = 0
  28. # n = n + Decimal(0.02)
  29. # end
  30. # end
  31. println("a")
  32. while n >= Decimal(0)
  33. if n == Decimal(0)
  34. column[string(n)] = .96
  35. else
  36. column[string(n)] = 1
  37. n = n + Decimal(0.02)
  38. end
  39. end
  40.  
  41. println("a")
  42.  
  43. # Add the first column to the array of values
  44. push!(values, column)
  45.  
  46. # Starting an infinite loop
  47. while true
  48. n = Decimal(-0.5)
  49. column = Dict()
  50.  
  51. # Creating the n'th column
  52. while n < Decimal(0.5)
  53. index = string(n)
  54. previousIndex = string(Decimal(n-Decimal(0.02)))
  55. if previousIndex == "-0.00"
  56. previousIndex = "0"
  57. end
  58. nextIndex = string((n+Decimal(0.02)))
  59. if index == "-0.5" || index == "0.5"
  60. column[index] = a + b*n^1 + c*n^2 + d*n^3
  61. else
  62. column[index] = Decimal(values[end][index] + (values[end][previousIndex]*phi - 2*values[end][index]*phi + values[end][nextIndex]*phi))
  63. end
  64. n = n+Decimal(0.02)
  65. end
  66.  
  67. if values[end]["0.48"] == values[end]["0.46"]
  68. break
  69. end
  70.  
  71. push!(values, column)
  72. t = t + 4
  73. end
  74. println(length(values))
  75. println(values[1]["-0.48"])
  76. println("done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement