Skip to content
Snippets Groups Projects
Commit 730192c6 authored by Stefan Arridge's avatar Stefan Arridge
Browse files

Added space struct as an argument to potential_init. Can use to set centre of...

Added space struct as an argument to potential_init. Can use to set centre of potential to be the box centre
parent b25e26cf
Branches
Tags
2 merge requests!272Added README files to examples,!271Stats include external potential energy
......@@ -9,7 +9,7 @@ InternalUnitSystem:
# Parameters governing the time integration
TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 0.1 # The end time of the simulation (in internal units).
time_end: 1.0 # The end time of the simulation (in internal units).
dt_min: 1e-6 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
......
......@@ -73,7 +73,7 @@ const_G = ((CONST_G_CGS*const_unit_mass_in_cgs*const_unit_time_in
print 'G=', const_G
# Parameters
periodic= 0 # 1 For periodic box
periodic= 1 # 1 For periodic box
boxSize = 4.
G = const_G
N = int(sys.argv[1]) # Number of particles
......@@ -128,6 +128,11 @@ coords += np.full((N,3),boxSize/2.)
print "x range = (%f,%f)" %(np.min(coords[:,0]),np.max(coords[:,0]))
print "y range = (%f,%f)" %(np.min(coords[:,1]),np.max(coords[:,1]))
print "z range = (%f,%f)" %(np.min(coords[:,2]),np.max(coords[:,2]))
print np.mean(coords[:,0])
print np.mean(coords[:,1])
print np.mean(coords[:,2])
ds = grp.create_dataset('Coordinates', (N, 3), 'd')
ds[()] = coords
coords = np.zeros(1)
......
......@@ -9,3 +9,5 @@ python makeIC.py 1000
python radial_profile.py 10
python internal_energy_profile.py 10
python test_energy_conservation.py
......@@ -435,7 +435,7 @@ int main(int argc, char *argv[]) {
/* Initialise the external potential properties */
struct external_potential potential;
if (with_external_gravity)
potential_init(params, &prog_const, &us, &potential);
potential_init(params, &prog_const, &us, &s, &potential);
if (with_external_gravity && myrank == 0) potential_print(&potential);
/* Initialise the cooling function properties */
......
......@@ -92,9 +92,9 @@
/* External gravity properties */
#define EXTERNAL_POTENTIAL_NONE
//#define EXTERNAL_POTENTIAL_NONE
//#define EXTERNAL_POTENTIAL_POINTMASS
//#define EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
#define EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
//#define EXTERNAL_POTENTIAL_DISC_PATCH
......
......@@ -36,9 +36,10 @@
void potential_init(const struct swift_params* parameter_file,
const struct phys_const* phys_const,
const struct UnitSystem* us,
const struct space* s,
struct external_potential* potential) {
potential_init_backend(parameter_file, phys_const, us, potential);
potential_init_backend(parameter_file, phys_const, us, s, potential);
}
/**
......
......@@ -47,6 +47,7 @@
void potential_init(const struct swift_params* parameter_file,
const struct phys_const* phys_const,
const struct UnitSystem* us,
const struct space* s,
struct external_potential* potential);
void potential_print(const struct external_potential* potential);
......
......@@ -34,6 +34,7 @@
#include "part.h"
#include "physical_constants.h"
#include "units.h"
#include "space.h"
/**
* @brief External Potential Properties - Disc patch case
......@@ -161,6 +162,7 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
static INLINE void potential_init_backend(
const struct swift_params* parameter_file,
const struct phys_const* phys_const, const struct UnitSystem* us,
const struct space* s,
struct external_potential* potential) {
potential->surface_density = parser_get_param_double(
......
......@@ -32,6 +32,7 @@
#include "part.h"
#include "physical_constants.h"
#include "units.h"
#include "space.h"
/**
* @brief External Potential Properties - Isothermal sphere case
......@@ -126,13 +127,14 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
static INLINE void potential_init_backend(
const struct swift_params* parameter_file,
const struct phys_const* phys_const, const struct UnitSystem* us,
const struct space* s,
struct external_potential* potential) {
potential->x =
potential->x = s->dim[0]/2. +
parser_get_param_double(parameter_file, "IsothermalPotential:position_x");
potential->y =
potential->y = s->dim[1]/2. +
parser_get_param_double(parameter_file, "IsothermalPotential:position_y");
potential->z =
potential->z = s->dim[2]/2. +
parser_get_param_double(parameter_file, "IsothermalPotential:position_z");
potential->vrot =
parser_get_param_double(parameter_file, "IsothermalPotential:vrot");
......
......@@ -31,6 +31,7 @@
#include "part.h"
#include "physical_constants.h"
#include "units.h"
#include "space.h"
/**
* @brief External Potential Properties
......@@ -81,6 +82,7 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
static INLINE void potential_init_backend(
const struct swift_params* parameter_file,
const struct phys_const* phys_const, const struct UnitSystem* us,
const struct space* s,
struct external_potential* potential) {}
/**
......
......@@ -32,6 +32,7 @@
#include "part.h"
#include "physical_constants.h"
#include "units.h"
#include "space.h"
/**
* @brief External Potential Properties - Point mass case
......@@ -127,6 +128,7 @@ __attribute__((always_inline)) INLINE static void external_gravity_acceleration(
static INLINE void potential_init_backend(
const struct swift_params* parameter_file,
const struct phys_const* phys_const, const struct UnitSystem* us,
const struct space* s,
struct external_potential* potential) {
potential->x =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment