Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
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
SWIFT
PySWIFTsim
Commits
2204383a
Commit
2204383a
authored
Mar 8, 2018
by
lhausamm
Browse files
Options
Downloads
Patches
Plain Diff
Update grackle structures
parent
ba5cfb0b
No related branches found
No related tags found
1 merge request
!4
Add cooling rate example
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyswiftsim/structure.py
+25
-31
25 additions, 31 deletions
pyswiftsim/structure.py
with
25 additions
and
31 deletions
pyswiftsim/structure.py
+
25
−
31
View file @
2204383a
from
pyswiftsim
import
wrapper
import
struct
import
numpy
from
ctypes
import
*
PARSER_MAX_LINE_SIZE
=
256
PARSER_MAX_NO_OF_PARAMS
=
256
PARSER_MAX_NO_OF_SECTIONS
=
64
######################################################################
# #
# SwiftStruct #
...
...
@@ -71,7 +71,6 @@ class SwiftStruct(struct.Struct):
"""
return
{}
def
_getInfoFromName
(
self
,
name
):
"""
Compute index, format and size from an attribute name.
...
...
@@ -105,7 +104,6 @@ class SwiftStruct(struct.Struct):
return
i
,
form
,
n
@property
def
struct_size_format
(
self
):
"""
...
...
@@ -147,7 +145,6 @@ class SwiftStruct(struct.Struct):
return
out_nber
,
out_form
def
__str__
(
self
,
tab
=
""
):
txt
=
tab
+
"
%s:
\n
"
%
type
(
self
)
for
name
in
self
.
struct_name
:
...
...
@@ -198,7 +195,6 @@ class SwiftStruct(struct.Struct):
data
=
struct
.
pack
(
nform
,
*
data
)
return
ArrayStruct
(
nform
,
data
,
self
,
name
)
def
__setattr__
(
self
,
name
,
value
):
# case where the attribute is not in the structure
if
name
not
in
self
.
struct_name
:
...
...
@@ -255,7 +251,6 @@ class ArrayStruct(SwiftStruct):
data
=
self
.
_clean
(
data
)
return
tab
+
str
(
data
)
+
"
\n
"
def
getArray
(
self
):
return
self
.
unpack
(
self
.
data
)
...
...
@@ -297,6 +292,7 @@ class ChemistryPartData(SwiftStruct):
def
__init__
(
self
,
data
,
parent
=
None
):
super
().
__init__
(
self
.
struct_format
,
data
,
parent
)
######################################################################
# #
# Part #
...
...
@@ -343,10 +339,10 @@ class Parameter(SwiftStruct):
"
value
"
]
def
__init__
(
self
,
data
,
parent
=
None
):
super
().
__init__
(
self
.
struct_format
,
data
,
parent
)
######################################################################
# #
# Section #
...
...
@@ -363,6 +359,7 @@ class Section(SwiftStruct):
def
__init__
(
self
,
data
,
parent
=
None
):
super
().
__init__
(
self
.
struct_format
,
data
,
parent
)
######################################################################
# #
# SwiftParams #
...
...
@@ -402,6 +399,7 @@ class SwiftParams(SwiftStruct):
"
data_params
"
:
param
}
######################################################################
# #
# PhysConst #
...
...
@@ -428,7 +426,6 @@ class PhysConst(SwiftStruct):
"
const_earth_mass
"
,
]
def
__init__
(
self
,
data
,
parent
=
None
):
super
().
__init__
(
self
.
struct_format
,
data
,
parent
)
...
...
@@ -451,6 +448,7 @@ class GrackleCodeUnits(SwiftStruct):
def
__init__
(
self
,
data
,
parent
=
None
):
super
().
__init__
(
self
.
struct_format
,
data
,
parent
)
class
GrackleChemistryData
(
SwiftStruct
):
cooling_type
=
wrapper
.
configGetCooling
()
_format
=
"
iiiiiPidiidiiiiiiidddiiddiddiiddddddiiiiii
"
...
...
@@ -504,6 +502,7 @@ class GrackleChemistryData(SwiftStruct):
def
__init__
(
self
,
data
,
parent
=
None
):
super
().
__init__
(
self
.
struct_format
,
data
,
parent
)
class
CoolingFunctionData
(
SwiftStruct
):
cooling_type
=
wrapper
.
configGetCooling
()
if
cooling_type
==
"
const_lambda
"
:
...
...
@@ -515,12 +514,8 @@ class CoolingFunctionData(SwiftStruct):
"
min_energy
"
,
"
cooling_tstep_mult
"
]
elif
cooling_type
in
[
"
grackle_double
"
,
"
grackle_float
"
]:
if
cooling_type
==
"
grackle_double
"
:
_format
=
"
200cidd
"
else
:
_format
=
"
200ciff
"
_format
+=
"
{code_units}s{chemistry}s
"
.
format
(
elif
"
grackle
"
in
cooling_type
:
_format
=
"
200cidd{code_units}s{chemistry}s
"
.
format
(
code_units
=
struct
.
calcsize
(
GrackleCodeUnits
.
_format
),
chemistry
=
struct
.
calcsize
(
GrackleChemistryData
.
_format
)
)
...
...
@@ -553,6 +548,5 @@ class CoolingFunctionData(SwiftStruct):
raise
ValueError
(
"
Cooling Type %s not implemented
"
%
cooling_type
)
def
__init__
(
self
,
data
,
parent
=
None
):
super
().
__init__
(
self
.
struct_format
,
data
,
parent
)
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
sign in
to comment