74
74
prob = discretize (pdesys,discretization)
75
75
end
76
76
77
- @testset " Kuramoto–Sivashinsky equation" begin
78
- @parameters x, t
79
- @variables u (.. )
80
- Dt = Differential (t)
81
- Dx = Differential (x)
82
- Dx2 = Differential (x)^ 2
83
- Dx3 = Differential (x)^ 3
84
- Dx4 = Differential (x)^ 4
85
-
86
- α = 1
87
- β = 4
88
- γ = 1
89
- eq = Dt (u (x,t)) ~ - u (x,t)* Dx (u (x,t)) - α* Dx2 (u (x,t)) - β* Dx3 (u (x,t)) - γ* Dx4 (u (x,t))
90
-
91
- u_analytic (x,t;z = - x/ 2 + t) = 11 + 15 * tanh (z) - 15 * tanh (z)^ 2 - 15 * tanh (z)^ 3
92
- du (x,t;z = - x/ 2 + t) = 15 / 2 * (tanh (z) + 1 )* (3 * tanh (z) - 1 )* sech (z)^ 2
93
-
94
- bcs = [u (x,0 ) ~ u_analytic (x,0 ),
95
- u (- 10 ,t) ~ u_analytic (- 10 ,t),
96
- u (10 ,t) ~ u_analytic (10 ,t),
97
- Dx (u (- 10 ,t)) ~ du (- 10 ,t),
98
- Dx (u (10 ,t)) ~ du (10 ,t)]
99
-
100
- # Space and time domains
101
- domains = [x ∈ Interval (- 10.0 ,10.0 ),
102
- t ∈ Interval (0.0 ,1.0 )]
103
- # Discretization
104
- dx = 0.4 ; dt = 0.2
105
-
106
- discretization = MOLFiniteDifference ([x=> dx],t;centered_order= 4 ,grid_align= center_align)
107
- pdesys = PDESystem (eq,bcs,domains,[x,t],[u (x,t)])
108
- prob = discretize (pdesys,discretization)
109
-
110
- sol = solve (prob,Tsit5 (),saveat= 0.1 ,dt= dt)
111
-
112
- @test sol. retcode == :Success
113
-
114
- xs = domains[1 ]. domain. lower+ dx+ dx: dx: domains[1 ]. domain. upper- dx- dx
115
- ts = sol. t
116
-
117
- u_predict = sol. u
118
- u_real = [[u_analytic (x, t) for x in xs] for t in ts]
119
- u_diff = u_real - u_predict
120
- @test_broken u_diff[:] ≈ zeros (length (u_diff)) atol= 0.01 ;
121
- # plot(xs, u_diff)
122
- end
123
-
124
77
@testset " KdV Single Soliton equation" begin
125
78
@parameters x, t
126
79
@variables u (.. )
163
116
164
117
u_predict = sol. u
165
118
u_real = [[u_analytic (x, t) for x in xs] for t in ts]
166
- u_diff = u_real - u_predict
167
- for i in 1 : length (u_diff)
168
- @test u_diff[i] ≈ zeros (length (u_diff[i])) atol= 0.05 ;
169
- end
119
+ @test all (isapprox .(u_predict, u_real, rtol = 0.03 ))
170
120
end
0 commit comments