feat(SpectralSolver): Spectral Solver now works in a limited fashion
Major work on spectral solver, can now evolve up to about a year. At that point we likely need to impliment repartitioning logic to stabalize the network or some other scheme based on the jacobian structure
This commit is contained in:
@@ -20,15 +20,7 @@
|
||||
#include <clocale>
|
||||
|
||||
#include "gridfire/reaction/reaclib.h"
|
||||
#include <omp.h>
|
||||
|
||||
unsigned long get_thread_id() {
|
||||
return static_cast<unsigned long>(omp_get_thread_num());
|
||||
}
|
||||
|
||||
bool in_parallel() {
|
||||
return omp_in_parallel() != 0;
|
||||
}
|
||||
|
||||
static std::terminate_handler g_previousHandler = nullptr;
|
||||
static std::vector<std::pair<double, std::unordered_map<std::string, std::pair<double, double>>>> g_callbackHistory;
|
||||
@@ -294,12 +286,6 @@ int main() {
|
||||
std::println("Total Time for {} runs: {:.6f} seconds", runs, elapsed.count());
|
||||
std::println("Final H-1 Abundances Serial: {}", serial_results[0].composition.getMolarAbundance(fourdst::atomic::H_1));
|
||||
|
||||
CppAD::thread_alloc::parallel_setup(
|
||||
static_cast<size_t>(omp_get_max_threads()), // Max threads
|
||||
[]() -> bool { return in_parallel(); }, // Function to get thread ID
|
||||
[]() -> size_t { return get_thread_id(); } // Function to check parallel state
|
||||
);
|
||||
|
||||
// OPTIONAL: Prevent CppAD from returning memory to the system
|
||||
// during execution to reduce overhead (can speed up tight loops)
|
||||
CppAD::thread_alloc::hold_memory(true);
|
||||
@@ -315,7 +301,6 @@ int main() {
|
||||
|
||||
// Parallel runs
|
||||
startTime = std::chrono::high_resolution_clock::now();
|
||||
#pragma omp parallel for
|
||||
for (size_t i = 0; i < runs; ++i) {
|
||||
auto start_setup_time = std::chrono::high_resolution_clock::now();
|
||||
solver::CVODESolverStrategy solver(construct.engine, *workspaces[i]);
|
||||
|
||||
@@ -4,8 +4,8 @@ executable(
|
||||
dependencies: [gridfire_dep, cli11_dep],
|
||||
)
|
||||
|
||||
#executable(
|
||||
# 'spectral_sandbox',
|
||||
# 'spectral_main.cpp',
|
||||
# dependencies: [gridfire_dep, cli11_dep]
|
||||
#)
|
||||
executable(
|
||||
'spectral_sandbox',
|
||||
'spectral_main.cpp',
|
||||
dependencies: [gridfire_dep, cli11_dep]
|
||||
)
|
||||
|
||||
@@ -60,7 +60,6 @@ std::vector<gridfire::NetIn> init(const double tMin, const double tMax, const do
|
||||
|
||||
netIn.tMax = evolveTime;
|
||||
netIn.dt0 = 1e-12;
|
||||
|
||||
netIns.push_back(netIn);
|
||||
}
|
||||
|
||||
@@ -80,11 +79,11 @@ int main(int argc, char** argv) {
|
||||
|
||||
CLI::App app{"GridFire Sandbox Application."};
|
||||
|
||||
double tMin = 1.0e7;
|
||||
double tMax = 2.5e7;
|
||||
double rhoMin = 1.0e2;
|
||||
double rhoMax = 1.0e4;
|
||||
double nShells = 5;
|
||||
double tMin = 1.5e7;
|
||||
double tMax = 1.7e7;
|
||||
double rhoMin = 1.5e2;
|
||||
double rhoMax = 1.5e2;
|
||||
double nShells = 15;
|
||||
double evolveTime = 3.1536e+16;
|
||||
|
||||
app.add_option("--tMin", tMin, "Minimum time in seconds");
|
||||
@@ -100,10 +99,10 @@ int main(int argc, char** argv) {
|
||||
|
||||
policy::MainSequencePolicy stellarPolicy(netIns[0].composition);
|
||||
stellarPolicy.construct();
|
||||
engine::DynamicEngine& engine = stellarPolicy.construct();
|
||||
policy::ConstructionResults construct = stellarPolicy.construct();
|
||||
|
||||
solver::SpectralSolverStrategy solver(engine);
|
||||
solver::SpectralSolverStrategy solver(construct.engine);
|
||||
std::vector<double> mass_coords = linspace(1e-5, 1.0, nShells);
|
||||
|
||||
std::vector<NetOut> results = solver.evaluate(netIns, mass_coords);
|
||||
std::vector<NetOut> results = solver.evaluate(netIns, mass_coords, *construct.scratch_blob);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user