Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flash-flood
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jp7g21
flash-flood
Commits
cd036439
Commit
cd036439
authored
2 months ago
by
Joe Pater
Browse files
Options
Downloads
Patches
Plain Diff
Dunno
parent
d86745d1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
fire2d.py
+21
-4
21 additions, 4 deletions
fire2d.py
with
21 additions
and
4 deletions
fire2d.py
+
21
−
4
View file @
cd036439
...
@@ -6,6 +6,7 @@ from numpy.linalg import inv
...
@@ -6,6 +6,7 @@ from numpy.linalg import inv
import
math
import
math
from
scipy.integrate
import
solve_ivp
from
scipy.integrate
import
solve_ivp
from
matplotlib
import
pyplot
as
plt
from
matplotlib
import
pyplot
as
plt
from
scipy.optimize
import
minimize
def
sum_to
(
k
):
def
sum_to
(
k
):
return
k
*
(
k
+
1
)
/
2
return
k
*
(
k
+
1
)
/
2
...
@@ -102,8 +103,23 @@ def solve(M, y0, T, delta_t):
...
@@ -102,8 +103,23 @@ def solve(M, y0, T, delta_t):
return
sln
,
i
+
1
return
sln
,
i
+
1
# def squared_change_rate(y, M):
# dy_dt = np.matmul(M, y) + np.exp(y)
# return np.dot(dy_dt, dy_dt)
# def sln_change(y, M):
# sln, i = solve(M, y, 10, 0.1)
# change = np.abs(sln[10,:] - y) - np.abs(sln[99,:] - y) - 1e6 * i**2
# return (change**2).sum()
# def get_equillibrium(M):
# ymin = minimize(lambda y: sln_change(y, M),
# 1*np.ones(M.shape[0]), method="Nelder-Mead")
# print(ymin)
# return ymin.x
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
mesh
=
Mesh2D
(
50
,
50
,
4
0
)
mesh
=
Mesh2D
(
50
,
50
,
6
0
)
# for k in range(mesh.N):
# for k in range(mesh.N):
# for j in range(mesh.N-k):
# for j in range(mesh.N-k):
# print("{:<5}".format(mesh[j,k]), end="")
# print("{:<5}".format(mesh[j,k]), end="")
...
@@ -112,7 +128,7 @@ if __name__ == "__main__":
...
@@ -112,7 +128,7 @@ if __name__ == "__main__":
M
=
construct_matrix
(
mesh
)
/
Da
M
=
construct_matrix
(
mesh
)
/
Da
ic_low
=
0
#3.4
ic_low
=
0
#3.4
ic_high
=
1
0
#3.4
ic_high
=
0
#3.4
i
=
0
i
=
0
while
i
<
100
:
while
i
<
100
:
...
@@ -125,10 +141,11 @@ if __name__ == "__main__":
...
@@ -125,10 +141,11 @@ if __name__ == "__main__":
sln
,
N_t_in_sln
=
solve
(
M
,
initial_conditions
,
simulation_time
,
time_step
)
sln
,
N_t_in_sln
=
solve
(
M
,
initial_conditions
,
simulation_time
,
time_step
)
print
(
ic
,
N_t_in_sln
)
print
(
ic
,
N_t_in_sln
)
if
N_t_in_sln
<
round
(
simulation_time
/
time_step
):
if
N_t_in_sln
<
round
(
simulation_time
/
time_step
):
ic_high
=
ic
ic_high
=
ic
else
:
else
:
if
i
>
5
0
:
if
i
>
0
:
break
break
ic_low
=
ic
ic_low
=
ic
...
@@ -140,7 +157,7 @@ if __name__ == "__main__":
...
@@ -140,7 +157,7 @@ if __name__ == "__main__":
P
=
mesh
.
get_plot_matrix
(
y_final
)
P
=
mesh
.
get_plot_matrix
(
y_final
)
temp_min
=
0.0
temp_min
=
0.0
temp_max
=
6
temp_max
=
0.5
# Determine subplot grid
# Determine subplot grid
ncols
=
4
ncols
=
4
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment