34 lines
896 B
C++
34 lines
896 B
C++
#include "api.hpp"
|
|
#include "state.hpp"
|
|
|
|
#include <cstddef>
|
|
|
|
PLUGIN_EXPORT std::uint32_t plugin_api_version(){
|
|
return PLUGIN_API_VERSION;
|
|
}
|
|
|
|
PLUGIN_EXPORT PluginType plugin_type(){
|
|
return PluginType::Solver;
|
|
}
|
|
|
|
PLUGIN_EXPORT const char* plugin_name(){
|
|
return "Runge-Kutta 4";
|
|
}
|
|
|
|
PLUGIN_EXPORT const char* plugin_description(){
|
|
return "Explicit fourth-order Runge-Kutta method";
|
|
}
|
|
|
|
PLUGIN_EXPORT void solver(const SolverParameters* parameters,
|
|
SolutionPoint* output,
|
|
size_t output_size){
|
|
State state{1, 0, 0};
|
|
output[0] = make_step(parameters->t_begin, state);
|
|
|
|
for (size_t index = 1; index < output_size; ++index){
|
|
state = runge_kutta_step(state, *parameters);
|
|
double t = parameters->t_begin + static_cast<double>(index) * parameters->step;
|
|
output[index] = make_step(t, state);
|
|
}
|
|
}
|