Skip to content
Snippets Groups Projects
Commit 02324c88 authored by lhausamm's avatar lhausamm
Browse files

Add grackle chemistry

parent 79af876e
No related branches found
No related tags found
1 merge request!486Add chemistry in part
......@@ -31,6 +31,8 @@
/* Import the right chemistry definition */
#if defined(CHEMISTRY_NONE)
#include "./chemistry/none/chemistry.h"
#elif defined(CHEMISTRY_GRACKLE)
#include "./chemistry/grackle/chemistry.h"
#else
#error "Invalid choice of chemistry function."
#endif
......
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_CHEMISTRY_NONE_H
#define SWIFT_CHEMISTRY_NONE_H
/**
* @file src/chemistry/none/chemistry.h
* @brief Empty infrastructure for the cases without chemistry function
*/
/* Some standard headers. */
#include <float.h>
#include <math.h>
/* Local includes. */
#include "chemistry_struct.h"
#include "error.h"
#include "hydro.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
#include "units.h"
/**
* @brief Sets the chemistry properties of the (x-)particles to a valid start
* state.
*
* Nothing to do here.
*
* @param p Pointer to the particle data.
* @param xp Pointer to the extended particle data.
*/
__attribute__((always_inline)) INLINE static void chemistry_init_part(
const struct part* restrict p, struct xpart* restrict xp) {}
/**
* @brief Initialises the chemistry properties.
*
* Nothing to do here.
*
* @param parameter_file The parsed parameter file.
* @param us The current internal system of units.
* @param phys_const The physical constants in internal units.
* @param chemistry The chemistry properties to initialize
*/
static INLINE void chemistry_init_backend(
const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const,
struct chemistry_part_data* chemistry) {}
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @param chemistry The properties of the chemistry function.
*/
static INLINE void chemistry_print_backend(
const struct chemistry_part_data* chemistry) {
message("Chemistry function is 'grackle'.");
}
#endif /* SWIFT_CHEMISTRY_NONE_H */
/*******************************************************************************
* This file is part of SWIFT.
* Coypright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "io_properties.h"
/**
* @brief Specifies which particle fields to read from a dataset
*
* @param parts The particle array.
* @param list The list of i/o properties to read.
* @param num_fields The number of i/o fields to read.
*/
void chemistry_read_particles(struct part* parts, struct io_props* list,
int* num_fields) {
list += *num_fields;
*num_fields += 1;
/* List what we want to read */
list[0] = io_make_input_field("HeDensity", FLOAT, 1, COMPULSORY,
UNIT_CONV_DENSITY, parts, chemistry_data.he_density);
}
/**
* @brief Specifies which particle fields to write to a dataset
*
* @param parts The particle array.
* @param list The list of i/o properties to write.
* @param num_fields The number of i/o fields to write.
*/
void chemistry_write_particles(const struct part* parts, struct io_props* list,
int* num_fields) {
list += *num_fields;
*num_fields += 1;
list[0] = io_make_output_field("HeDensity", FLOAT, 1, UNIT_CONV_LENGTH,
parts, chemistry_data.he_density);
}
/**
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
void writeChemistryFlavor(hid_t h_grpsph) {
/* Viscosity and thermal conduction */
io_write_attribute_s(
h_grpsph, "Chemistry Model",
"Grackle");
}
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_CHEMISTRY_STRUCT_NONE_H
#define SWIFT_CHEMISTRY_STRUCT_NONE_H
/**
* @file src/chemistry/none/chemistry_struct.h
* @brief Empty infrastructure for the cases without chemistry function
*/
/**
* @brief Properties of the chemistry function.
*/
struct chemistry_part_data {
float he_density;
};
#endif /* SWIFT_CHEMISTRY_STRUCT_NONE_H */
......@@ -25,6 +25,8 @@
/* Import the right functions */
#if defined(CHEMISTRY_NONE)
#include "./chemistry/none/chemistry_io.h"
#elif defined(CHEMISTRY_GRACKLE)
#include "./chemistry/grackle/chemistry_io.h"
#else
#error "Invalid choice of chemistry function."
#endif
......
......
......@@ -30,6 +30,8 @@
/* Import the right chemistry definition */
#if defined(CHEMISTRY_NONE)
#include "./chemistry/none/chemistry_struct.h"
#elif defined(CHEMISTRY_GRACKLE)
#include "./chemistry/grackle/chemistry_struct.h"
#else
#error "Invalid choice of chemistry function."
#endif
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment