@@ -9,7 +9,7 @@ f = (t,x) -> (-5).*exp.((-25).*((3/2)+6.*t.^2+x[:,1]+x[:,1].^2+x[:,2]+x[:,2].^2+
9
9
T = 2
10
10
dx = 1 // 2 ^ (3 )
11
11
dt = 1 // 2 ^ (9 )
12
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
12
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
13
13
"""
14
14
Example problem defined by the solution:
15
15
```math
@@ -18,7 +18,7 @@ u(x,y,t)=\\frac{1}{10}(1-\\exp(-100(t-\\frac{1}{2})^2))\\exp(-25((x-t+0.5)^2 + (
18
18
19
19
This will have a mound which moves across the screen. Good animation test.
20
20
"""
21
- prob_femheat_moving = HeatProblem (analytic_moving,Du,f,fem_mesh )
21
+ prob_femheat_moving = HeatProblem (analytic_moving,Du,f,mesh )
22
22
23
23
N = 2 # Number of different dt to solve at, 2 for test speed
24
24
topdt = 6 # 1//2^(topdt-1) is the max dt. Small for test speed
@@ -39,7 +39,7 @@ cs_femheat_moving_dx = ConvergenceSetup(probs,dxs)
39
39
T = 1
40
40
dx = 1 // 2 ^ (3 )
41
41
dt = 1 // 2 ^ (7 )
42
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
42
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
43
43
"""
44
44
Example problem defined by the solution:
45
45
```math
@@ -48,15 +48,15 @@ u(x,y,t)=\\frac{1}{10}(1-\\exp(-100(t-\\frac{1}{2})^2))\\exp(-25((x-t+0.5)^2 + (
48
48
49
49
This will have a mound which moves across the screen. Good animation test.
50
50
"""
51
- prob_femheat_moving7 = HeatProblem (analytic_moving,Du,f,fem_mesh )
51
+ prob_femheat_moving7 = HeatProblem (analytic_moving,Du,f,mesh )
52
52
53
53
analytic_diffuse (t,x) = exp .(- 10 ((x[:,1 ]- .5 ). ^ 2 + (x[:,2 ]- .5 ). ^ 2 )- t)
54
54
f = (t,x) -> exp .(- t- 5 * (1 - 2 x[:,1 ]+ 2 x[:,1 ]. ^ 2 - 2 x[:,2 ] + 2 x[:,2 ]. ^ 2 )).* (- 161 + 400 * (x[:,1 ] - x[:,1 ]. ^ 2 + x[:,2 ] - x[:,2 ]. ^ 2 ))
55
55
Du = (t,x) -> - 20 [analytic_diffuse (t,x).* (x[:,1 ]- .5 ) analytic_diffuse (t,x).* (x[:,2 ]- .5 )]
56
56
T = 1
57
57
dx = 1 // 2 ^ (3 )
58
58
dt = 1 // 2 ^ (7 )
59
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
59
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
60
60
"""
61
61
Example problem defined by the solution:
62
62
@@ -66,63 +66,68 @@ u(x,y,t)=\\exp(-10((x-\\frac{1}{2})^2 + (y-\\frac{1}{2})^2 )-t)
66
66
67
67
This is a Gaussian centered at ``(\\ frac{1}{2},\\ frac{1}{2})`` which diffuses over time.
68
68
"""
69
- prob_femheat_diffuse = HeatProblem (analytic_diffuse,Du,f,fem_mesh )
69
+ prob_femheat_diffuse = HeatProblem (analytic_diffuse,Du,f,mesh )
70
70
71
71
72
72
f = (t,x) -> zeros (size (x,1 ))
73
- u0 = (x) -> float ((abs .(x[:,1 ]- .5 ) .< 1e-6 ) & (abs .(x[:,2 ]- .5 ) .< 1e-6 )) # Only mass at middle of (0,1)^2
73
+ u0_func = (x) -> float ((abs .(x[:,1 ]- .5 ) .< 1e-6 ) & (abs .(x[:,2 ]- .5 ) .< 1e-6 )) # Only mass at middle of (0,1)^2
74
74
T = 1 // 2 ^ (5 )
75
75
dx = 1 // 2 ^ (3 )
76
76
dt = 1 // 2 ^ (9 )
77
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
77
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
78
+ u0 = u0_func (mesh. node)
78
79
"""
79
80
Example problem which starts with a Dirac δ cenetered at (0.5,0.5) and solves with ``f=gD=0``.
80
81
This gives the Green's function solution.
81
82
"""
82
- prob_femheat_pure = HeatProblem (u0,f,fem_mesh )
83
+ prob_femheat_pure = HeatProblem (u0,f,mesh )
83
84
84
85
T = 1 // 2 ^ (5 )
85
86
dt = 1 // 2 ^ (11 )
86
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
87
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:dirichlet )
88
+ u0 = u0_func (mesh. node)
87
89
"""
88
90
Example problem which starts with a Dirac δ cenetered at (0.5,0.5) and solves with ``f=gD=0``.
89
91
This gives the Green's function solution.
90
92
"""
91
- prob_femheat_pure11 = HeatProblem (u0,f,fem_mesh )
93
+ prob_femheat_pure11 = HeatProblem (u0,f,mesh )
92
94
93
95
f = (t,x,u) -> ones (size (x,1 )) - .5 u
94
- u0 = (x) -> zeros (size (x,1 ))
96
+ u0_func = (x) -> zeros (size (x,1 ))
95
97
T = 1
96
98
dx = 1 // 2 ^ (3 )
97
99
dt = 1 // 2 ^ (7 )
98
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
100
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
101
+ u0 = u0_func (mesh. node)
99
102
"""
100
103
Homogenous reaction-diffusion problem which starts with 0 and solves with ``f(u)=1-u/2``
101
104
"""
102
- prob_femheat_birthdeath = HeatProblem (u0,f,fem_mesh )
105
+ prob_femheat_birthdeath = HeatProblem (u0,f,mesh )
103
106
104
107
105
108
f = (t,x,u) -> [ones (size (x,1 ))- .5 u[:,1 ] ones (size (x,1 ))- u[:,2 ]]
106
- u0 = (x) -> ones (size (x,1 ),2 ).* [.5 .5 ] # size (x,2), 2 meaning 2 variables
109
+ u0_func = (x) -> ones (size (x,1 ),2 ).* [.5 .5 ] # size (x,2), 2 meaning 2 variables
107
110
T = 5
108
111
dx = 1 / 2 ^ (1 )
109
112
dt = 1 / 2 ^ (7 )
110
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
113
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
114
+ u0 = u0_func (mesh. node)
111
115
"""
112
116
Homogenous reaction-diffusion which starts at 1/2 and solves the system ``f(u)=1-u/2`` and ``f(v)=1-v``
113
117
"""
114
- prob_femheat_birthdeathsystem = HeatProblem (u0,f,fem_mesh )
118
+ prob_femheat_birthdeathsystem = HeatProblem (u0,f,mesh )
115
119
116
120
f = (t,x,u) -> [ones (size (x,1 ))- .5 u[:,1 ] .5 u[:,1 ]- u[:,2 ]]
117
- u0 = (x) -> ones (size (x,1 ),2 ).* [.5 .5 ] # size (x,2), 2 meaning 2 variables
121
+ u0_func = (x) -> ones (size (x,1 ),2 ).* [.5 .5 ] # size (x,2), 2 meaning 2 variables
118
122
T = 5
119
123
dx = 1 / 2 ^ (1 )
120
124
dt = 1 / 2 ^ (7 )
121
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
125
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
126
+ u0 = u0_func (mesh. node)
122
127
"""
123
128
Homogenous reaction-diffusion which starts with 1/2 and solves the system ``f(u)=1-u/2`` and ``f(v)=.5u-v``
124
129
"""
125
- prob_femheat_birthdeathinteractingsystem = HeatProblem (u0,f,fem_mesh )
130
+ prob_femheat_birthdeathinteractingsystem = HeatProblem (u0,f,mesh )
126
131
127
132
#=
128
133
f = (t,x,u) -> [zeros(size(x,1)) zeros(size(x,1))]
@@ -131,7 +136,7 @@ u0 = (x) -> [float((abs.(x[:,1]-.5) .< 1e-6) & (abs.(x[:,2]-.5) .< 1e-6)) float(
131
136
Example problem which solves the homogeneous Heat equation with all mass starting at (1/2,1/2) with two different diffusion constants,
132
137
``D₁=0.01`` and ``D₂=0.001``. Good animation test.
133
138
"""
134
- prob_femheat_diffusionconstants = HeatProblem(u0,f,fem_mesh ,D=[.01 .001])
139
+ prob_femheat_diffusionconstants = HeatProblem(u0,f,mesh ,D=[.01 .001])
135
140
=#
136
141
137
142
#=
@@ -193,76 +198,80 @@ end
193
198
=#
194
199
195
200
f = (t,x,u) -> ones (size (x,1 )) - .5 u
196
- u0 = (x) -> zeros (size (x,1 ))
201
+ u0_func = (x) -> zeros (size (x,1 ))
197
202
σ = (t,x,u) -> 1 u.^ 2
198
203
T = 5
199
204
dx = 1 // 2 ^ (3 )
200
205
dt = 1 // 2 ^ (5 )
201
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
206
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
207
+ u0 = u0_func (mesh. node)
202
208
"""
203
209
Homogenous stochastic reaction-diffusion problem which starts with 0
204
210
and solves with ``f(u)=1-u/2`` with noise ``σ(u)=10u^2``
205
211
"""
206
- prob_femheat_stochasticbirthdeath = HeatProblem (u0,f,fem_mesh ,σ= σ)
212
+ prob_femheat_stochasticbirthdeath = HeatProblem (u0,f,mesh ,σ= σ)
207
213
208
214
dx = 1 // 2 ^ (1 )
209
215
dt = 1 // 2 ^ (1 )
210
- fem_mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
211
- prob_femheat_stochasticbirthdeath_fast = HeatProblem (u0,f,fem_mesh,σ= σ)
216
+ mesh = parabolic_squaremesh ([0 1 0 1 ],dx,dt,T,:neumann )
217
+ u0 = u0_func (mesh. node)
218
+ prob_femheat_stochasticbirthdeath_fast = HeatProblem (u0,f,mesh,σ= σ)
212
219
213
220
# # Poisson
214
221
215
222
f = (x) -> sin .(2 π.* x[:,1 ]).* cos .(2 π.* x[:,2 ])
216
223
analytic = (x) -> sin .(2 π.* x[:,1 ]).* cos .(2 π.* x[:,2 ])/ (8 π* π)
217
224
Du = (x) -> [cos .(2 * pi .* x[:,1 ]).* cos .(2 * pi .* x[:,2 ])./ (4 * pi ) - sin .(2 π.* x[:,1 ]).* sin .(2 π.* x[:,2 ])./ (4 π)]
218
225
dx = 1 // 2 ^ (5 )
219
- fem_mesh = notime_squaremesh ([0 1 0 1 ],dx,:dirichlet )
226
+ mesh = notime_squaremesh ([0 1 0 1 ],dx,:dirichlet )
220
227
"""
221
228
Problem defined by the solution: ``u(x,y)= \\ sin(2πx)\\ cos(2πy)/(8π^2)``
222
229
"""
223
- prob_poisson_wave = PoissonProblem (f,analytic,Du,fem_mesh )
230
+ prob_poisson_wave = PoissonProblem (f,analytic,Du,mesh )
224
231
225
232
dxs = 1. // 2. ^ (4 : - 1 : 2 ) # 4 for testing, use 7 for good graph
226
233
probs = [PoissonProblem (f,analytic,Du,notime_squaremesh ([0 1 0 1 ],dx,:dirichlet )) for dx in dxs]
227
234
cs_fempoisson_wave = ConvergenceSetup (probs,dts)
228
235
229
236
σ = (x) -> 5 # Additive noise
230
237
dx = 1 // 2 ^ (5 )
231
- fem_mesh = notime_squaremesh ([0 1 0 1 ],dx,:dirichlet )
238
+ mesh = notime_squaremesh ([0 1 0 1 ],dx,:dirichlet )
232
239
"""
233
240
Problem with deterministic solution: ``u(x,y)= \\ sin(2πx)\\ cos(2πy)/(8π^2)``
234
241
and additive noise ``σ(x,y)=5``
235
242
"""
236
- prob_poisson_noisywave = PoissonProblem (f,analytic,Du,fem_mesh ,σ= σ)
243
+ prob_poisson_noisywave = PoissonProblem (f,analytic,Du,mesh ,σ= σ)
237
244
238
245
f = (x,u) -> ones (size (x,1 )) - .5 u
239
246
dx = 1 // 2 ^ (3 )
240
- fem_mesh = notime_squaremesh ([0 1 0 1 ],dx,:neumann )
247
+ mesh = notime_squaremesh ([0 1 0 1 ],dx,:neumann )
241
248
"""
242
249
Nonlinear Poisson equation with ``f(u)=1-u/2``.
243
250
Corresponds to the steady state of a humogenous reaction-diffusion equation
244
251
with the same ``f``.
245
252
"""
246
- prob_poisson_birthdeath = PoissonProblem (f,fem_mesh ,numvars= 1 )
253
+ prob_poisson_birthdeath = PoissonProblem (f,mesh ,numvars= 1 )
247
254
248
255
f = (x,u) -> [ones (size (x,1 ))- .5 u[:,1 ] ones (size (x,1 ))- u[:,2 ]]
249
- u0 = (x) -> .5 * ones (size (x,1 ),2 ) # size (x,2), 2 meaning 2 variables
256
+ u0_func = (x) -> .5 * ones (size (x,1 ),2 ) # size (x,2), 2 meaning 2 variables
250
257
dx = 1 // 2 ^ (1 )
251
- fem_mesh = notime_squaremesh ([0 1 0 1 ],dx,:neumann )
258
+ mesh = notime_squaremesh ([0 1 0 1 ],dx,:neumann )
259
+ u0 = u0_func (mesh. node)
252
260
"""
253
261
Nonlinear Poisson equation with ``f(u)=1-u/2`` and ``f(v)=1-v`` and initial
254
262
condition homogenous 1/2. Corresponds to the steady state of a humogenous
255
263
reaction-diffusion equation with the same ``f``.
256
264
"""
257
- prob_poisson_birthdeathsystem = PoissonProblem (f,fem_mesh ,u0= u0)
265
+ prob_poisson_birthdeathsystem = PoissonProblem (f,mesh ,u0= u0)
258
266
259
267
f = (x,u) -> [ones (size (x,1 ))- .5 u[:,1 ] .5 u[:,1 ]- u[:,2 ]]
260
- u0 = (x) -> ones (size (x,1 ),2 ).* [.5 .5 ] # size (x,2), 2 meaning 2 variables
268
+ u0_func = (x) -> ones (size (x,1 ),2 ).* [.5 .5 ] # size (x,2), 2 meaning 2 variables
261
269
dx = 1 // 2 ^ (1 )
262
- fem_mesh = notime_squaremesh ([0 1 0 1 ],dx,:neumann )
270
+ mesh = notime_squaremesh ([0 1 0 1 ],dx,:neumann )
271
+ u0 = u0_func (mesh. node)
263
272
"""
264
273
Nonlinear Poisson equation with ``f(u)=1-u/2`` and ``f(v)=.5u-v`` and initial
265
274
condition homogenous 1/2. Corresponds to the steady state of a humogenous
266
275
reaction-diffusion equation with the same ``f``.
267
276
"""
268
- prob_poisson_birthdeathinteractingsystem = PoissonProblem (f,fem_mesh ,u0= u0)
277
+ prob_poisson_birthdeathinteractingsystem = PoissonProblem (f,mesh ,u0= u0)
0 commit comments