Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
9b493672
Commit
9b493672
authored
6 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Don't apply any unit conversions, run VELOCIraptor in SWIFT units.
parent
54c67c37
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!578
Swift velociraptor
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/velociraptor_interface.c
+14
-28
14 additions, 28 deletions
src/velociraptor_interface.c
with
14 additions
and
28 deletions
src/velociraptor_interface.c
+
14
−
28
View file @
9b493672
...
@@ -50,18 +50,6 @@ void velociraptor_init(struct engine *e) {
...
@@ -50,18 +50,6 @@ void velociraptor_init(struct engine *e) {
struct
unitinfo
unit_info
;
struct
unitinfo
unit_info
;
struct
siminfo
sim_info
;
struct
siminfo
sim_info
;
struct
phys_const
vel_const
;
if
(
posix_memalign
((
void
**
)
&
(
e
->
stf_units
),
32
,
sizeof
(
struct
unit_system
))
!=
0
)
error
(
"Failed to allocate VELOCIraptor unit system."
);
if
(
posix_memalign
((
void
**
)
&
(
e
->
stf_conv_fac
),
32
,
sizeof
(
struct
unitinfo
))
!=
0
)
error
(
"Failed to allocate VELOCIraptor conversion factors."
);
/* Initialize velociraptor unit system and constants */
units_init_from_params
(
e
->
stf_units
,
e
->
parameter_file
,
"VelociraptorUnitSystem"
);
phys_const_init
(
e
->
stf_units
,
e
->
parameter_file
,
&
vel_const
);
/* Set cosmological constants. */
/* Set cosmological constants. */
cosmo_info
.
atime
=
e
->
cosmology
->
a
;
cosmo_info
.
atime
=
e
->
cosmology
->
a
;
cosmo_info
.
littleh
=
e
->
cosmology
->
h
;
cosmo_info
.
littleh
=
e
->
cosmology
->
h
;
...
@@ -80,13 +68,12 @@ void velociraptor_init(struct engine *e) {
...
@@ -80,13 +68,12 @@ void velociraptor_init(struct engine *e) {
message
(
"w_de: %e"
,
cosmo_info
.
w_de
);
message
(
"w_de: %e"
,
cosmo_info
.
w_de
);
/* Set unit conversions. */
/* Set unit conversions. */
e
->
stf_conv_fac
->
lengthtokpc
=
units_conversion_factor
(
e
->
internal_units
,
e
->
stf_units
,
UNIT_CONV_LENGTH
);
/* 1kpc <=> 3.086e21cm */
unit_info
.
lengthtokpc
=
1
.
0
;
e
->
stf_conv_fac
->
velocitytokms
=
units_conversion_factor
(
e
->
internal_units
,
e
->
stf_units
,
UNIT_CONV_SPEED
);
/* 1km/s <=> 1e5cm/s */
unit_info
.
velocitytokms
=
1
.
0
;
e
->
stf_conv_fac
->
masstosolarmass
=
units_conversion_factor
(
e
->
internal_units
,
e
->
stf_units
,
UNIT_CONV_MASS
);
/* 1M_sol <=> 1.99e33g */
unit_info
.
masstosolarmass
=
1
.
0
;
e
->
stf_conv_fac
->
energyperunitmass
=
units_conversion_factor
(
e
->
internal_units
,
e
->
stf_units
,
UNIT_CONV_ENERGY_PER_UNIT_MASS
);
/* Conversion for gravitational potential. */
unit_info
.
energyperunitmass
=
1
.
0
;
e
->
stf_conv_fac
->
gravity
=
vel_const
.
const_newton_G
;
/* TODO: G = 6.67408e-8 (cgs) */
unit_info
.
gravity
=
e
->
physical_constants
->
const_newton_G
;
e
->
stf_conv_fac
->
hubbleunit
=
e
->
cosmology
->
H
;
/* TODO: double check this. */
unit_info
.
hubbleunit
=
e
->
cosmology
->
H
;
/* TODO: double check this. */
unit_info
=
*
e
->
stf_conv_fac
;
message
(
"Length conversion factor: %e"
,
unit_info
.
lengthtokpc
);
message
(
"Length conversion factor: %e"
,
unit_info
.
lengthtokpc
);
message
(
"Velocity conversion factor: %e"
,
unit_info
.
velocitytokms
);
message
(
"Velocity conversion factor: %e"
,
unit_info
.
velocitytokms
);
...
@@ -170,7 +157,6 @@ void velociraptor_invoke(struct engine *e) {
...
@@ -170,7 +157,6 @@ void velociraptor_invoke(struct engine *e) {
const
size_t
nr_hydro_parts
=
s
->
nr_parts
;
const
size_t
nr_hydro_parts
=
s
->
nr_parts
;
const
int
nr_cells
=
s
->
nr_cells
;
const
int
nr_cells
=
s
->
nr_cells
;
int
*
cell_node_ids
=
NULL
;
int
*
cell_node_ids
=
NULL
;
struct
unitinfo
*
conv_fac
=
e
->
stf_conv_fac
;
/* Allow thread to run on any core for the duration of the call to VELOCIraptor so that
/* Allow thread to run on any core for the duration of the call to VELOCIraptor so that
* when OpenMP threads are spawned they can run on any core on the processor. */
* when OpenMP threads are spawned they can run on any core on the processor. */
...
@@ -224,14 +210,14 @@ void velociraptor_invoke(struct engine *e) {
...
@@ -224,14 +210,14 @@ void velociraptor_invoke(struct engine *e) {
/* Convert particle properties into VELOCIraptor units */
/* Convert particle properties into VELOCIraptor units */
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
nr_gparts
;
i
++
)
{
swift_parts
[
i
].
x
[
0
]
=
gparts
[
i
].
x
[
0
]
*
conv_fac
->
lengthtokpc
;
swift_parts
[
i
].
x
[
0
]
=
gparts
[
i
].
x
[
0
];
swift_parts
[
i
].
x
[
1
]
=
gparts
[
i
].
x
[
1
]
*
conv_fac
->
lengthtokpc
;
swift_parts
[
i
].
x
[
1
]
=
gparts
[
i
].
x
[
1
];
swift_parts
[
i
].
x
[
2
]
=
gparts
[
i
].
x
[
2
]
*
conv_fac
->
lengthtokpc
;
swift_parts
[
i
].
x
[
2
]
=
gparts
[
i
].
x
[
2
];
swift_parts
[
i
].
v
[
0
]
=
gparts
[
i
].
v_full
[
0
]
*
conv_fac
->
velocitytokms
/
a2
;
swift_parts
[
i
].
v
[
0
]
=
gparts
[
i
].
v_full
[
0
]
/
a2
;
swift_parts
[
i
].
v
[
1
]
=
gparts
[
i
].
v_full
[
1
]
*
conv_fac
->
velocitytokms
/
a2
;
swift_parts
[
i
].
v
[
1
]
=
gparts
[
i
].
v_full
[
1
]
/
a2
;
swift_parts
[
i
].
v
[
2
]
=
gparts
[
i
].
v_full
[
2
]
*
conv_fac
->
velocitytokms
/
a2
;
swift_parts
[
i
].
v
[
2
]
=
gparts
[
i
].
v_full
[
2
]
/
a2
;
swift_parts
[
i
].
mass
=
gparts
[
i
].
mass
*
conv_fac
->
masstosolarmass
;
swift_parts
[
i
].
mass
=
gparts
[
i
].
mass
;
swift_parts
[
i
].
potential
=
gparts
[
i
].
potential
*
conv_fac
->
energyperunitmass
;
swift_parts
[
i
].
potential
=
gparts
[
i
].
potential
;
swift_parts
[
i
].
type
=
gparts
[
i
].
type
;
swift_parts
[
i
].
type
=
gparts
[
i
].
type
;
/* Set gas particle IDs from their hydro counterparts and set internal energies. */
/* Set gas particle IDs from their hydro counterparts and set internal energies. */
...
...
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