Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jigyasa Watwani
/
growth-pattern-control
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9c9e18c1
authored
Apr 10, 2022
by
Jigyasa Watwani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checked for errors, all clear
parent
068520dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
no_c_fixed_bdry_fft.py
no_c_fixed_bdry_fft.py
View file @
9c9e18c1
...
...
@@ -3,7 +3,26 @@ from scipy.integrate import odeint
import
matplotlib.pyplot
as
plt
from
matplotlib.widgets
import
Slider
from
mpl_toolkits.axes_grid1
import
make_axes_locatable
import
time
import
progressbar
#parameters
Lx
=
2
*
np
.
pi
Nx
=
200
T
=
100
dt
=
0.1
Nt
=
int
(
T
/
dt
)
times
=
np
.
linspace
(
0
,
T
,
Nt
)
K
=
1
eta
=
1
lamda
=
1
krho
=
1
rho0
=
1
Drho
=
1
x
=
np
.
linspace
(
0
,
Lx
,
Nx
)
q
=
np
.
fft
.
fftshift
(
np
.
fft
.
fftfreq
(
len
(
x
),
d
=
Lx
/
(
2
*
np
.
pi
*
Nx
)))
def
reaction_rho
(
rho
,
rho0
,
krho
):
return
(
-
krho
*
(
rho
-
rho0
))
...
...
@@ -14,7 +33,7 @@ def time_derivative(c, t):
# compute FFT
uq
=
np
.
fft
.
fftshift
(
np
.
fft
.
fft
(
u
))
rhoq
=
np
.
fft
.
fftshift
(
np
.
fft
.
fft
(
rho
))
rhoq
=
np
.
fft
.
fftshift
(
np
.
fft
.
fft
(
rho
-
rho0
))
vq
=
(
-
K
*
q
**
2
*
uq
+
1
j
*
q
*
lamda
*
rhoq
)
/
(
1
+
eta
*
q
**
2
)
# RHS in Fourier-space
...
...
@@ -27,37 +46,19 @@ def time_derivative(c, t):
return
np
.
concatenate
([
RHS_u
,
RHS_rho
])
#parameters
Lx
=
2
*
np
.
pi
Nx
=
100
T
=
100
dt
=
0.01
Nt
=
int
(
T
/
dt
)
times
=
np
.
linspace
(
0
,
T
,
Nt
)
K
=
1
eta
=
1
lamda
=
8
krho
=
1
rho0
=
1
Drho
=
1
x
=
np
.
linspace
(
0
,
Lx
,
Nx
)
q
=
np
.
fft
.
fftshift
(
np
.
fft
.
fftfreq
(
len
(
x
),
d
=
Lx
/
(
2
*
np
.
pi
*
Nx
)))
# initial conditions
u0
=
np
.
sin
(
x
)
rho0
=
np
.
cos
(
x
)
u00
=
np
.
sin
(
x
)
# u00 = u00 * np.ones_like(x) + 0.01 * np.random.randn(x.shape[0])
rho00
=
np
.
cos
(
x
)
+
np
.
cos
(
x
/
2
)
# rho00 = rho00 * np.ones_like(x) + 0.01 * np.random.randn(x.shape[0])
c0
=
np
.
concatenate
([
u0
,
rho
0
])
c0
=
np
.
concatenate
([
u0
0
,
rho0
0
])
#integrate in time
c
=
odeint
(
time_derivative
,
c0
,
times
)
#split and reshape solution arrays
u
,
rho
=
np
.
split
(
c
,
2
,
axis
=
1
)
u
=
u
.
reshape
((
Nt
,
Nx
))
rho
=
rho
.
reshape
((
Nt
,
Nx
))
#plotting
fig
,
(
axu
,
axrho
)
=
plt
.
subplots
(
2
,
1
,
sharex
=
True
,
figsize
=
(
8
,
6
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment