Commit 79086ca2 authored by Cianciosa, Mark's avatar Cianciosa, Mark
Browse files

Use gamma next in posiiton update,

parent 2d4589dd
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ void run_korc() {
            
            auto u_next = (u_prime + u_prime_dot_t*t + u_prime->cross(t))/s;
            
            auto pos_next = pos + larmor_radius*dt*u_next/gamma;
            auto pos_next = pos + larmor_radius*dt*u_next/gamma_next;
            
            work.add_item({
                graph::variable_cast(x),
@@ -143,14 +143,15 @@ void run_korc() {
            const timeing::measure_diagnostic t_run("Run Time");
            work.pre_run();
            for (size_t i = 0; i < 1000000; i++) {
                sync.join();
                /*sync.join();
                work.wait();
                sync = std::thread([&file, &dataset] () -> void {
                    dataset.write(file);
                });
                });*/
                
                work.run();
            }
            work.wait();

            sync.join();
            dataset.write(file);
+44 −0
Original line number Diff line number Diff line
@@ -4,6 +4,10 @@
//------------------------------------------------------------------------------
#include "../graph_framework/jit.hpp"

#include <numbers>

#include "../graph_framework/equilibrium.hpp"

//------------------------------------------------------------------------------
///  @brief Main program of the playground.
///
@@ -17,7 +21,47 @@ int main(int argc, const char * argv[]) {

//  Insert code here. No code should be commited to this file beyond this
//  template.
    auto r = graph::variable<double> (1000, "r");
    auto phi = graph::variable<double> (1000, "\\phi");
    auto z = graph::variable<double> (1000, "z");

    auto eq = equilibrium::make_efit<double> (EFIT_FILE);

    auto bvec = eq->get_magnetic_field(r*graph::cos(phi),
                                       r*graph::sin(phi),
                                       z);

    bvec->get_x()->to_latex();
    std::cout << "\\\\" << std::endl;
    bvec->get_y()->to_latex();
    std::cout << "\\\\" << std::endl;
    bvec->get_z()->to_latex();
    std::cout << "\\\\" << std::endl;
    std::cout << std::endl << std::endl << std::endl;

    r->set(static_cast<double> (1.7));
    z->set(static_cast<double> (0.0));
    std::vector<double> temp(1000);
    for (size_t i = 0; i < 1000; i++) {
        temp[i] = 2.0*std::numbers::pi_v<double>*i/999.0;
    }
    phi->set(temp);

    workflow::manager<double> work(0);
    work.add_item({
        graph::variable_cast(r),
        graph::variable_cast(phi),
        graph::variable_cast(z)
    }, {
        bvec->get_x(),
        bvec->get_y(),
        bvec->get_z()
    }, {}, "bvec_kernel");
    work.compile();
    work.run();
    for (size_t i = 0; i < 1000; i++) {
        work.print(i, {r, phi, z, bvec->get_x(), bvec->get_y(), bvec->get_z()});
    }

    END_GPU
}