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
bddc5d10
Commit
bddc5d10
authored
8 years ago
by
Tom Theuns
Browse files
Options
Downloads
Patches
Plain Diff
added timestep multiplier as extra parameter
parent
961a5ca3
No related branches found
No related tags found
1 merge request
!205
Isothermal potential
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/IsothermalPotential/GravityOnly/externalGravity.yml
+3
-2
3 additions, 2 deletions
examples/IsothermalPotential/GravityOnly/externalGravity.yml
src/potentials.c
+10
-4
10 additions, 4 deletions
src/potentials.c
src/potentials.h
+6
-2
6 additions, 2 deletions
src/potentials.h
with
19 additions
and
8 deletions
examples/IsothermalPotential/GravityOnly/externalGravity.yml
+
3
−
2
View file @
bddc5d10
...
@@ -63,11 +63,12 @@ PointMass:
...
@@ -63,11 +63,12 @@ PointMass:
position_y
:
50.
position_y
:
50.
position_z
:
50.
position_z
:
50.
mass
:
1e10
# mass of external point mass in internal units
mass
:
1e10
# mass of external point mass in internal units
timestep_mult
:
0.03
# controls time step
IsothermalPotential
:
IsothermalPotential
:
position_x
:
100.
# location of
ext
er
n
al po
int mass
in internal units
position_x
:
100.
# location of
centre of isoth
er
m
al po
tential
in internal units
position_y
:
100.
position_y
:
100.
position_z
:
100.
position_z
:
100.
vrot
:
200.
# rotation speed of isothermal potential in internal units
vrot
:
200.
# rotation speed of isothermal potential in internal units
timestep_mult
:
0.03
# controls time step
This diff is collapsed.
Click to expand it.
src/potentials.c
+
10
−
4
View file @
bddc5d10
...
@@ -46,6 +46,8 @@ void potential_init(const struct swift_params* parameter_file,
...
@@ -46,6 +46,8 @@ void potential_init(const struct swift_params* parameter_file,
parser_get_param_double
(
parameter_file
,
"PointMass:position_z"
);
parser_get_param_double
(
parameter_file
,
"PointMass:position_z"
);
potential
->
point_mass
.
mass
=
potential
->
point_mass
.
mass
=
parser_get_param_double
(
parameter_file
,
"PointMass:mass"
);
parser_get_param_double
(
parameter_file
,
"PointMass:mass"
);
potential
->
point_mass
.
timestep_mult
=
parser_get_param_double
(
parameter_file
,
"PointMass:timestep_mult"
);
#endif
/* EXTERNAL_POTENTIAL_POINTMASS */
#endif
/* EXTERNAL_POTENTIAL_POINTMASS */
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
...
@@ -57,6 +59,8 @@ void potential_init(const struct swift_params* parameter_file,
...
@@ -57,6 +59,8 @@ void potential_init(const struct swift_params* parameter_file,
parser_get_param_double
(
parameter_file
,
"IsothermalPotential:position_z"
);
parser_get_param_double
(
parameter_file
,
"IsothermalPotential:position_z"
);
potential
->
isothermal_potential
.
vrot
=
potential
->
isothermal_potential
.
vrot
=
parser_get_param_double
(
parameter_file
,
"IsothermalPotential:vrot"
);
parser_get_param_double
(
parameter_file
,
"IsothermalPotential:vrot"
);
potential
->
isothermal_potential
.
timestep_mult
=
parser_get_param_double
(
parameter_file
,
"IsothermalPotential:timestep_mult"
);
#endif
/* EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL */
#endif
/* EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL */
}
}
...
@@ -68,13 +72,15 @@ void potential_init(const struct swift_params* parameter_file,
...
@@ -68,13 +72,15 @@ void potential_init(const struct swift_params* parameter_file,
void
potential_print
(
const
struct
external_potential
*
potential
)
{
void
potential_print
(
const
struct
external_potential
*
potential
)
{
#ifdef EXTERNAL_POTENTIAL_POINTMASS
#ifdef EXTERNAL_POTENTIAL_POINTMASS
message
(
"Point mass properties are (x,y,z) = (%e, %e, %e), M = %e"
,
message
(
"Point mass properties are (x,y,z) = (%e, %e, %e), M =
%e timestep multiplier =
%e"
,
potential
->
point_mass
.
x
,
potential
->
point_mass
.
y
,
potential
->
point_mass
.
x
,
potential
->
point_mass
.
y
,
potential
->
point_mass
.
z
,
potential
->
point_mass
.
mass
);
potential
->
point_mass
.
z
,
potential
->
point_mass
.
mass
,
potential
->
point_mass
.
timestep_mult
);
#endif
/* EXTERNAL_POTENTIAL_POINTMASS */
#endif
/* EXTERNAL_POTENTIAL_POINTMASS */
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
message
(
"Isothermal potential properties are (x,y,z) = (%e, %e, %e), vrot = %e"
,
message
(
"Isothermal potential properties are (x,y,z) = (%e, %e, %e), vrot =
%e timestep multiplier=
%e"
,
potential
->
isothermal_potential
.
x
,
potential
->
isothermal_potential
.
y
,
potential
->
isothermal_potential
.
x
,
potential
->
isothermal_potential
.
y
,
potential
->
isothermal_potential
.
z
,
potential
->
isothermal_potential
.
vrot
);
potential
->
isothermal_potential
.
z
,
potential
->
isothermal_potential
.
vrot
,
potential
->
isothermal_potential
.
timestep_mult
);
#endif
/* EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL */
#endif
/* EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL */
}
}
This diff is collapsed.
Click to expand it.
src/potentials.h
+
6
−
2
View file @
bddc5d10
...
@@ -42,12 +42,14 @@ struct external_potential {
...
@@ -42,12 +42,14 @@ struct external_potential {
struct
{
struct
{
double
x
,
y
,
z
;
double
x
,
y
,
z
;
double
mass
;
double
mass
;
double
timestep_mult
;
}
point_mass
;
}
point_mass
;
#endif
#endif
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
struct
{
struct
{
double
x
,
y
,
z
;
double
x
,
y
,
z
;
double
vrot
;
double
vrot
;
double
timestep_mult
;
}
isothermal_potential
;
}
isothermal_potential
;
#endif
#endif
};
};
...
@@ -83,7 +85,8 @@ __attribute__((always_inline))
...
@@ -83,7 +85,8 @@ __attribute__((always_inline))
// error(" dx= %e dvx= %e rinv2= %e a2= %e dota_2= %e dt= %e", dx, g->v_full[1], rinv2, a_2, dota_2, 0.03f * sqrtf(a_2 / dota_2));
// error(" dx= %e dvx= %e rinv2= %e a2= %e dota_2= %e dt= %e", dx, g->v_full[1], rinv2, a_2, dota_2, 0.03f * sqrtf(a_2 / dota_2));
return
EXTERNAL_GRAVITY_TIMESTEP_PREFACTOR
*
sqrtf
(
a_2
/
dota_2
);
//return EXTERNAL_GRAVITY_TIMESTEP_PREFACTOR * sqrtf(a_2 / dota_2);
return
potential
->
isothermal_potential
.
timestep_mult
*
sqrtf
(
a_2
/
dota_2
);
}
}
/**
/**
* @brief Computes the gravitational acceleration of a particle due to a point
* @brief Computes the gravitational acceleration of a particle due to a point
...
@@ -142,7 +145,8 @@ external_gravity_pointmass_timestep(const struct external_potential* potential,
...
@@ -142,7 +145,8 @@ external_gravity_pointmass_timestep(const struct external_potential* potential,
const
float
a_2
=
g
->
a_grav
[
0
]
*
g
->
a_grav
[
0
]
+
g
->
a_grav
[
1
]
*
g
->
a_grav
[
1
]
+
const
float
a_2
=
g
->
a_grav
[
0
]
*
g
->
a_grav
[
0
]
+
g
->
a_grav
[
1
]
*
g
->
a_grav
[
1
]
+
g
->
a_grav
[
2
]
*
g
->
a_grav
[
2
];
g
->
a_grav
[
2
]
*
g
->
a_grav
[
2
];
return
EXTERNAL_GRAVITY_TIMESTEP_PREFACTOR
*
sqrtf
(
a_2
/
dota_2
);
/* return EXTERNAL_GRAVITY_TIMESTEP_PREFACTOR * sqrtf(a_2 / dota_2); */
return
potential
->
point_mass
.
timestep_mult
*
sqrtf
(
a_2
/
dota_2
);
}
}
/**
/**
...
...
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