feat(partition-functions): added framework and some concrete partition functions

GroundState partition function, Rauscher&Thielemann partition function, and composite partition function added
This commit is contained in:
2025-07-02 11:32:45 -04:00
parent a14738d597
commit e5ad284778
13 changed files with 70432 additions and 10 deletions

View File

@@ -0,0 +1,43 @@
#pragma once
#include "gridfire/partition/partition_abstract.h"
#include "fourdst/logging/logging.h"
#include <string>
#include <unordered_map>
#include <vector>
#include <memory>
namespace gridfire::partition {
enum BasePartitionType {
RauscherThielemann, ///< Rauscher-Thielemann partition function
GroundState, ///< Ground state partition function
};
inline std::unordered_map<BasePartitionType, std::string> basePartitionTypeToString = {
{RauscherThielemann, "RauscherThielemann"},
{GroundState, "GroundState"}
};
inline std::unordered_map<std::string, BasePartitionType> stringToBasePartitionType = {
{"RauscherThielemann", RauscherThielemann},
{"GroundState", GroundState}
};
class CompositePartitionFunction final : public PartitionFunction {
public:
explicit CompositePartitionFunction(const std::vector<BasePartitionType>& partitionFunctions);
double evaluate(int z, int a, double T9) const override;
double evaluateDerivative(int z, int a, double T9) const override;
bool supports(int z, int a) const override;
std::string type() const override;
private:
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
std::vector<std::unique_ptr<PartitionFunction>> m_partitionFunctions; ///< Set of partition functions to use in the composite partition function.
private:
std::unique_ptr<PartitionFunction> selectPartitionFunction(const BasePartitionType type) const;
};
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <string>
namespace gridfire::partition {
class PartitionFunction {
public:
virtual ~PartitionFunction() = default;
virtual double evaluate(int z, int a, double T9) const = 0;
virtual double evaluateDerivative(int z, int a, double T9) const = 0;
virtual bool supports(int z, int a) const = 0;
virtual std::string type() const = 0;
};
}

View File

@@ -0,0 +1,38 @@
#pragma once
#include "gridfire/partition/partition_abstract.h"
#include "fourdst/logging/logging.h"
#include <unordered_map>
#include "quill/Logger.h"
namespace gridfire::partition {
class GroundStatePartitionFunction final : public PartitionFunction {
public:
GroundStatePartitionFunction();
double evaluate(
const int z,
const int a,
const double T9
) const override;
double evaluateDerivative(
const int z,
const int a,
const double T9
) const override;
bool supports(
const int z,
const int a
) const override;
std::string type() const override { return "GroundState"; }
private:
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
std::unordered_map<int, double> m_ground_state_spin;
static constexpr int make_key(
const int z,
const int a);
};
}

View File

@@ -0,0 +1,56 @@
#pragma once
#include "gridfire/partition/partition_abstract.h"
#include "fourdst/logging/logging.h"
#include <string>
#include <vector>
#include <unordered_map>
#include <array>
#include <utility>
namespace gridfire::partition {
class RauscherThielemannPartitionFunction final : public PartitionFunction {
public:
RauscherThielemannPartitionFunction();
double evaluate(int z, int a, double T9) const override;
double evaluateDerivative(int z, int a, double T9) const override;
bool supports(int z, int a) const override;
std::string type() const override { return "RauscherThielemann"; }
private:
enum Bounds {
FRONT,
BACK,
MIDDLE
};
private:
struct IsotopeData {
double ground_state_spin;
std::array<double, 24> normalized_g_values;
};
struct InterpolationPoints {
double T9_high;
double G_norm_high;
double T9_low;
double G_norm_low;
};
struct IdentifiedIsotope {
Bounds bound;
const IsotopeData& data;
size_t upperIndex;
size_t lowerIndex;
};
private:
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
std::unordered_map<int, IsotopeData> m_partitionData;
private:
static InterpolationPoints get_interpolation_points(
const size_t upper_index,
const size_t lower_index,
const std::array<double, 24>& normalized_g_values
);
IdentifiedIsotope find(int z, int a, double T9) const;
static constexpr int make_key(int z, int a);
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
#pragma once
#include <cstdint>
namespace gridfire::partition::record {
#pragma pack(push, 1)
struct RauscherThielemannPartitionDataRecord {
uint32_t z; ///< Atomic number
uint32_t a; ///< Mass number
double ground_state_spin; ///< Ground state spin
double partition_function; ///< Partition function value
double normalized_g_values[24]; ///< Normalized g-values for the first 24 energy levels
};
#pragma pack(pop)
}