Skip to content

Commit ec0e239

Browse files
Setting micro driver class and sketching integrators
1 parent eaccbf5 commit ec0e239

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

native/include/m_driver.h

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include<iostream>
33
#include "c_micro_sim.h"
44

5+
class Integrator; // forward declaration
56
// Base class for the drivers
67
class Driver {
78
public:
@@ -13,15 +14,37 @@ class Driver {
1314
double * alpha;
1415
double gamma;
1516
double t;
17+
MicroSim * sim;
18+
Integrator * integrator;
19+
20+
virtual void run_until(double t) {};
1621
};
1722

1823

19-
class Integrator_RK4 {
24+
// Abstract class
25+
class Integrator {
26+
public:
27+
Integrator() {};
28+
virtual void _setup(int N) {};
29+
// Allow magnetisation to update (via LLG + effective field)
30+
// TODO: figure out how to set the update function in Driver class
31+
virtual void compute_RHS(void (* f) (double * m, double t)) {};
32+
}
33+
34+
// Integrators should be independent of any driver/sim class
35+
class Integrator_RK4: public Integrator {
2036
public:
2137
Integrator_RK4() {};
2238
virtual ~Integrator_RK4() {std::cout << "Killing RK4 integrator\n";};
2339
// Will get the parameters from a simulation class
2440
// void _setup(MicroSim * sim, Driver * driver);
25-
std::vector<double> rk_steps; // N * 4 array
26-
void integration_step(double (*f)(double t, double y));
41+
std::vector<double> rk1; // N array
42+
std::vector<double> rk2; // N array
43+
std::vector<double> rk3; // N array
44+
std::vector<double> rk4; // N array
45+
void integration_step(double (*f)(double t, double m)); // compute_RHS ??
46+
void _setup(int N);
47+
int N;
48+
double t;
49+
double dt;
2750
};

native/src/m_driver.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "m_driver.h"
2+
3+
void Integrator_RK4::_setup(int N) {
4+
this->rk_steps(N * 4, 0.0);
5+
}

0 commit comments

Comments
 (0)