Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F109620619
gbms_collisions_input.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
Tue, Apr 22, 17:55
Size
3 KB
Mime Type
text/x-python
Expires
Thu, Apr 24, 17:55 (2 d)
Engine
blob
Format
Raw Data
Handle
25741179
Attached To
rCOSOLVER COSOlver
gbms_collisions_input.py
View Options
#!/usr/bin/env python
# generates *.h5 files as input for molix
import
os
import
sys
import
h5py
as
h5
if
len
(
sys
.
argv
)
==
2
:
cwd
=
sys
.
argv
[
1
]
# define file names (default values)
eicolls_filename
=
'ei.h5'
iecolls_filename
=
'ie.h5'
eecolls_filename
=
'self.h5'
iicolls_filename
=
'self.h5'
# define output filename
out_filename
=
'collisions.h5'
elif
len
(
sys
.
argv
)
==
7
:
cwd
=
sys
.
argv
[
1
]
eicolls_filename
=
sys
.
argv
[
2
]
iecolls_filename
=
sys
.
argv
[
3
]
eecolls_filename
=
sys
.
argv
[
4
]
iicolls_filename
=
sys
.
argv
[
5
]
out_filename
=
sys
.
argv
[
6
]
else
:
print
(
'You need to include a path to the directory, or to write it manualy in this script'
)
exit
(
2
)
# Define directories
# cwd = os.getcwd()
#cwd = ''
# Where to find the cosolver *.h5 files
#cosolver_dir = os.path.join(cwd, 'self.h5')
#cosolver_dir = cwd
# Define size of matrices (all matrices are assumed to have the same size)
Pmaxi
=
16
Jmaxi
=
8
Pmaxe
=
16
Jmaxe
=
8
eicolls_file
=
os
.
path
.
join
(
cwd
,
eicolls_filename
)
iecolls_file
=
os
.
path
.
join
(
cwd
,
iecolls_filename
)
eecolls_file
=
os
.
path
.
join
(
cwd
,
eecolls_filename
)
iicolls_file
=
os
.
path
.
join
(
cwd
,
iicolls_filename
)
# Define output filename
outputfilename
=
os
.
path
.
join
(
cwd
,
out_filename
)
# Open the h5 files in read mode
eih5
=
h5
.
File
(
eicolls_file
,
'r'
)
ieh5
=
h5
.
File
(
iecolls_file
,
'r'
)
eeh5
=
h5
.
File
(
eecolls_file
,
'r'
)
iih5
=
h5
.
File
(
iicolls_file
,
'r'
)
#selfh5 = h5.File(selfcolls_file, 'r')
#selfeeh5 = h5.File( selfeecolls_file, 'r')
# Create ouput file
outh5
=
h5
.
File
(
outputfilename
,
'w'
)
# Flush ei/ie/ee/ii collisions to output h5 file
dst_CeipjF
=
outh5
.
create_dataset
(
"/00000/Ceipj/CeipjF"
,
data
=
eih5
[
'/Ceipj/CeipjF'
])
dst_CeipjF
.
attrs
[
'Pmaxe'
]
=
Pmaxe
dst_CeipjF
.
attrs
[
'Jmaxe'
]
=
Jmaxe
dst_CeipjT
=
outh5
.
create_dataset
(
"/00000/Ceipj/CeipjT"
,
data
=
eih5
[
'/Ceipj/CeipjT'
])
dst_CeipjT
.
attrs
[
'Jmaxe'
]
=
Jmaxe
dst_CeipjT
.
attrs
[
'Pmaxe'
]
=
Pmaxe
outh5
.
create_dataset
(
"/00000/Ceipj/fort.90"
,
data
=
eih5
[
'/files/fort.90'
])
dst_CiepjF
=
outh5
.
create_dataset
(
"/00000/Ciepj/CiepjF"
,
data
=
ieh5
[
'/Ciepj/CiepjF'
])
dst_CiepjF
.
attrs
[
'Pmaxi'
]
=
Pmaxi
dst_CiepjF
.
attrs
[
'Jmaxi'
]
=
Jmaxi
dst_CiepjT
=
outh5
.
create_dataset
(
"/00000/Ciepj/CiepjT"
,
data
=
ieh5
[
'/Ciepj/CiepjT'
])
dst_CiepjT
.
attrs
[
'Pmaxi'
]
=
Pmaxi
dst_CiepjT
.
attrs
[
'Jmaxi'
]
=
Jmaxi
outh5
.
create_dataset
(
"/00000/Ciepj/fort.90"
,
data
=
ieh5
[
'/files/fort.90'
])
dst_Cii
=
outh5
.
create_dataset
(
"/00000/Ciipj"
,
data
=
iih5
[
'/Caapj/Ciipj'
])
dst_Cii
.
attrs
[
'Pmaxi'
]
=
Pmaxi
dst_Cii
.
attrs
[
'Jmaxi'
]
=
Jmaxi
outh5
.
create_dataset
(
"/00000/Cii/fort.90"
,
data
=
iih5
[
'/files/fort.90'
])
dst_Cee
=
outh5
.
create_dataset
(
"/00000/Ceepj"
,
data
=
eeh5
[
'/Caapj/Ceepj'
])
#dst_Cee= outh5.create_dataset("/00000/Ceepj", data = selfh5['/Caapj/Ceepj'])
dst_Cee
.
attrs
[
'Pmaxe'
]
=
Pmaxe
dst_Cee
.
attrs
[
'Jmaxe'
]
=
Jmaxe
outh5
.
create_dataset
(
"/00000/Cee/fort.90"
,
data
=
eeh5
[
'/files/fort.90'
])
outh5
.
create_dataset
(
"/dims_i"
,
data
=
[
Pmaxi
,
Jmaxi
])
outh5
.
create_dataset
(
"/dims_e"
,
data
=
[
Pmaxe
,
Jmaxe
])
# Set to 0 for DK collision operators
outh5
.
create_dataset
(
"/coordkperp"
,
data
=
[
0
])
# Close file
outh5
.
close
()
print
(
'Created '
+
outputfilename
)
Event Timeline
Log In to Comment