Skip to content

Instantly share code, notes, and snippets.

@Rafka86
Rafka86 / Solver.cs
Last active August 16, 2018 07:23
Heun法
public static void Heun(NumericalModelWithODE model) => Heun(model, Console.Out);
public static void Heun(NumericalModelWithODE model, TextWriter file) {
var t = model.TimeStart;
var te = model.TimeEnd;
var x = model.InitialValues;
file.WriteLine($"{t} {x}");
while (t <= te) {
x += HeunUpdate();
@Rafka86
Rafka86 / Solver.cs
Created August 16, 2018 07:21
ルンゲ=クッタ法
public static void Rk4(NumericalModelWithODE model) => Rk4(model, Console.Out);
public static void Rk4(NumericalModelWithODE model, TextWriter file) {
var t = model.TimeStart;
var te = model.TimeEnd;
var x = model.InitialValues;
const double frac6 = 1.0 / 6.0;
var hDelta = Delta * 0.5;
file.WriteLine($"{t} {x}");
@Rafka86
Rafka86 / Solver.cs
Created August 17, 2018 16:31
数値解法クラス決定版
using System;
using System.IO;
namespace NumericalLib {
public static class Solver {
private enum NumericalMethod {
Euler,
Heun,
Rk4
@Rafka86
Rafka86 / Program.cs
Created August 17, 2018 16:50
斜方投射のシミュレーション
using System.IO;
using NumericalLib;
using static System.Math;
namespace Projection {
class Program {
private class Projection : NumericalModelWithODE {