Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80595911
heat_distribution.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 1, 14:14
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Sep 3, 14:14 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20400483
Attached To
R9484 sp4e-homework-lars-bertil
heat_distribution.py
View Options
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Lars Blatny and Bertil Trottet
"""
import
numpy
as
np
###################### DOMAIN PARAMETERS #################################
N
=
256
L
=
2.0
R
=
1.0
###################### GRID OF POINTS #####################################
x
=
np
.
linspace
(
-
L
/
2
,
L
/
2
,
N
)
y
=
np
.
linspace
(
-
L
/
2
,
L
/
2
,
N
)
xv
,
yv
=
np
.
meshgrid
(
x
,
y
,
sparse
=
False
,
indexing
=
'ij'
)
zv
=
np
.
zeros
((
N
,
N
))
vx
=
np
.
zeros
((
N
,
N
))
vy
=
np
.
zeros
((
N
,
N
))
vz
=
np
.
zeros
((
N
,
N
))
fx
=
np
.
zeros
((
N
,
N
))
fy
=
np
.
zeros
((
N
,
N
))
fz
=
np
.
zeros
((
N
,
N
))
m
=
np
.
zeros
((
N
,
N
))
Temperature
=
np
.
zeros
((
N
,
N
))
hv
=
np
.
zeros
((
N
,
N
))
for
i
in
range
(
N
):
for
j
in
range
(
N
):
if
(
xv
[
i
][
j
]
**
2
+
yv
[
i
][
j
]
**
2
<
R
**
2
):
hv
[
i
][
j
]
=
1.0
################# WRITE CSV FILE (TO USE AS INPUT FOR SIMULATION) ##########
f
=
open
(
'x_y_z_vx_vy_vz_fx_fy_fz_m_T_hv.csv'
,
"w"
)
#'x_y_z_vx_vy_vz_fx_fy_fz_m_T_hv.csv'
for
i
in
range
(
N
):
for
j
in
range
(
N
):
f
.
write
(
str
(
round
(
xv
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
yv
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
zv
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
vx
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
vy
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
vz
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
fx
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
fy
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
fz
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
m
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
Temperature
[
i
][
j
],
3
))
+
' '
+
str
(
round
(
hv
[
i
][
j
],
3
)))
f
.
write
(
'
\n
'
)
f
.
close
()
Event Timeline
Log In to Comment