refactor(GridFire): updated outputs

This commit is contained in:
2026-04-13 07:19:18 -04:00
parent d1872cb65a
commit 5a1a904e71
10 changed files with 704 additions and 291 deletions

View File

@@ -5,10 +5,8 @@
#include <thread>
#include <format>
#include "gridfire/gridfire.h"
#include <cppad/utility/thread_alloc.hpp> // Required for parallel_setup
#include "fourdst/composition/composition.h"
#include "fourdst/logging/logging.h"
#include "fourdst/atomic/species.h"
#include "fourdst/composition/utils.h"
@@ -19,6 +17,8 @@
#include <clocale>
#include "gridfire/gridfire.h"
#include "fourdst/composition/composition.h"
#include "gridfire/utils/gf_omp.h"
@@ -229,31 +229,21 @@ void callback_main(const gridfire::solver::PointSolverTimestepContext& ctx) {
}
int main() {
GF_PAR_INIT();
using namespace gridfire;
constexpr size_t breaks = 1;
double temp = 1.5e7;
double rho = 1.5e2;
double tMax = 3.1536e+16/breaks;
constexpr double temp = 1.5e7;
constexpr double rho = 1.6e2;
constexpr double tMax = 3e17;
const NetIn netIn = init(temp, rho, tMax);
policy::MainSequencePolicy stellarPolicy(netIn.composition);
auto [engine, ctx_template] = stellarPolicy.construct();
std::println("Sandbox Engine Stack: {}", stellarPolicy);
std::println("Scratch Blob State: {}", *ctx_template);
constexpr size_t nZones = 100;
std::array<NetIn, nZones> netIns;
for (size_t zone = 0; zone < nZones; ++zone) {
netIns[zone] = netIn;
netIns[zone].temperature = 1.5e7;
}
auto engine = engine::GraphEngine(netIn.composition, engine::NetworkBuildDepth::Full);
auto blob = engine.constructStateBlob();
const solver::PointSolver localSolver(engine);
solver::GridSolverContext solverCtx(*ctx_template);
const solver::GridSolver gridSolver(engine, localSolver);
solver::PointSolverContext solverCtx(*blob);
std::vector<NetOut> netOuts = gridSolver.evaluate(solverCtx, netIns | std::ranges::to<std::vector>());
auto result = localSolver.evaluate(solverCtx, netIn, false, false);
std::cout << result << std::endl;
}

View File

@@ -6,6 +6,8 @@ from fourdst.composition import CanonicalComposition
from fourdst.atomic import Species
from gridfire.type import NetIn
from logger import StepLogger
def rescale_composition(comp_ref : Composition, ZZs : float, Y_primordial : float = 0.248) -> Composition:
CC : CanonicalComposition = comp_ref.getCanonicalComposition()
@@ -61,13 +63,17 @@ def years_to_seconds(years: float) -> float:
def main():
C = init_composition()
netIn = init_netIn(2.75e6, 1.5e1, years_to_seconds(10e9), C)
netIn = init_netIn(1.5e7, 1.6e2, years_to_seconds(10e9), C)
policy = MainSequencePolicy(C)
construct = policy.construct()
solver = PointSolver(construct.engine)
solver_ctx = PointSolverContext(construct.scratch_blob)
results = solver.evaluate(solver_ctx, netIn, False, False)
print(results)
stepLogger = StepLogger()
solver_ctx.callback = lambda ctx: stepLogger.log_step(ctx);
solver.evaluate(solver_ctx, netIn, False, False)
stepLogger.to_json("test_single.json", TestName="test_single");
if __name__ == "__main__":
main()