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
0b650d6b
Commit
0b650d6b
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Allow the users to overwrite the value of Newton's constant via the YAML file.
parent
a0e0089d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/main.c
+1
-1
1 addition, 1 deletion
examples/main.c
examples/parameter_example.yml
+4
-0
4 additions, 0 deletions
examples/parameter_example.yml
src/physical_constants.c
+13
-0
13 additions, 0 deletions
src/physical_constants.c
src/physical_constants.h
+2
-0
2 additions, 0 deletions
src/physical_constants.h
with
20 additions
and
1 deletion
examples/main.c
+
1
−
1
View file @
0b650d6b
...
...
@@ -589,7 +589,7 @@ int main(int argc, char *argv[]) {
/* Not restarting so look for the ICs. */
/* Initialize unit system and constants */
units_init
(
&
us
,
params
,
"InternalUnitSystem"
);
phys_const_init
(
&
us
,
&
prog_const
);
phys_const_init
(
&
us
,
params
,
&
prog_const
);
if
(
myrank
==
0
&&
verbose
>
0
)
{
message
(
"Internal unit system: U_M = %e g."
,
us
.
UnitMass_in_cgs
);
message
(
"Internal unit system: U_L = %e cm."
,
us
.
UnitLength_in_cgs
);
...
...
This diff is collapsed.
Click to expand it.
examples/parameter_example.yml
+
4
−
0
View file @
0b650d6b
...
...
@@ -6,6 +6,10 @@ InternalUnitSystem:
UnitCurrent_in_cgs
:
1
# Amperes
UnitTemp_in_cgs
:
1
# Kelvin
# Values of some physical constants
PhysicalConstants
:
G
:
6.67408e-8
# (Optional) Overwrite the value of Newton's constant used internally by the code.
# Parameters for the task scheduling
Scheduler
:
nr_queues
:
0
# (Optional) The number of task queues to use. Use 0 to let the system decide.
...
...
This diff is collapsed.
Click to expand it.
src/physical_constants.c
+
13
−
0
View file @
0b650d6b
...
...
@@ -32,10 +32,14 @@
/**
* @brief Converts physical constants to the internal unit system
*
* Some constants can be overwritten by the YAML file values.
*
* @param us The current internal system of units.
* @param params The parsed parameter file.
* @param internal_const The physical constants to initialize.
*/
void
phys_const_init
(
const
struct
unit_system
*
us
,
const
struct
swift_params
*
params
,
struct
phys_const
*
internal_const
)
{
/* Units are declared as {U_M, U_L, U_t, U_I, U_T} */
...
...
@@ -44,6 +48,10 @@ void phys_const_init(const struct unit_system *us,
internal_const
->
const_newton_G
=
const_newton_G_cgs
/
units_general_cgs_conversion_factor
(
us
,
dimension_G
);
/* Overwrite G if present in the file */
internal_const
->
const_newton_G
=
parser_get_opt_param_double
(
params
,
"PhysicalConstants:G"
,
internal_const
->
const_newton_G
);
const
float
dimension_c
[
5
]
=
{
0
,
1
,
-
1
,
0
,
0
};
internal_const
->
const_speed_light_c
=
const_speed_light_c_cgs
/
...
...
@@ -111,6 +119,11 @@ void phys_const_init(const struct unit_system *us,
units_general_cgs_conversion_factor
(
us
,
dimension_length
);
}
/**
* @brief Print the value of the physical constants to stdout.
*
* @param internal_const The constants in the internal unit system.
*/
void
phys_const_print
(
const
struct
phys_const
*
internal_const
)
{
message
(
"%25s = %e"
,
"Gravitational constant"
,
...
...
This diff is collapsed.
Click to expand it.
src/physical_constants.h
+
2
−
0
View file @
0b650d6b
...
...
@@ -29,6 +29,7 @@
#include
"../config.h"
/* Local includes. */
#include
"parser.h"
#include
"units.h"
/**
...
...
@@ -89,6 +90,7 @@ struct phys_const {
};
void
phys_const_init
(
const
struct
unit_system
*
us
,
const
struct
swift_params
*
params
,
struct
phys_const
*
internal_const
);
void
phys_const_print
(
const
struct
phys_const
*
internal_const
);
...
...
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