欧拉谐振子 [英] Euler harmonics oscillator

查看:116
本文介绍了欧拉谐振子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有一个谐波振荡器定义:

f = -k / r + b / r ^ 5 (中心力//位置//我将称之为快速)

如果我做得好,那么快速是:v_n + 1 = v_n + Delta_t *( - k / m * r + b / m * 1 / r ^ 5)

我叫v_nr = Delta_t *( - k / m * r + b / m * 1 / r ^ 5)



所以位置r是:r_n + 1 = r_n + Delta_t * v_nr +1/2。(r_n + 1 - r_n-1)



我需要找到v(t)和r(t)。

我首先尝试在没有b项的情况下解决这个问题(这是一个扰动项)



我尝试了什么:



Hello,

I've got a Harmonic Oscillator define by :
f=-k/r + b/r^5 (central force // r the position // and I will call v the celerity)
if I did well the celerity is: v_n+1 = v_n + Delta_t *( - k/m*r+ b/m*1/r^5)
I call v_nr = Delta_t *( - k/m*r+ b/m*1/r^5)

And so the position r is: r_n+1 = r_n + Delta_t * v_nr +1/2.(r_n+1 - r_n-1)

I need to find the v(t) and r(t).
I first try to solve this without the b term (which is a perturbation term)

What I have tried:

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#define M 3 // in kg
#define k 1.0  //  kg/sec^2
#define N 50   // interation

double T = 2*pi*(m/k)^0.5;

double main (void) {  // initiation
  double r=0.0; double rr=0.0;
  double v=10.0; double vr=0.0;
}

int main() {

    FILE *fichier;
    fichier = fopen("without b perturbation", "w+");
    int t=0 ;
    for(t = 0; t <= N; t++) {
        rr = r + T * v ;
        vr = v + T * k/m *r ;
        v = v + T * ((k * x / m) + (k * xint / m)) / 2.0;
        x = x + (h) * (v + vint) / 2.0;
	r = rr + T * (v+vr);
	v = v
	r=rr;
	fprintf(fichier, "%d\t%lf\n", t, yy);
	printf("%d\t%lf\n", t, yy);
    }
    fclose(fichier);
    return 0;
}

推荐答案

您正在尝试解决二阶微分方程,这不像它看起来那么简单。 Runge-Kutta系列是一个基本的求解器系列。谷歌提供有关推导,如何使用等的更多信息。



许多其他求解器也存在,每个求解器都针对不同的方程特征进行了优化。



BTW,你的函数 double main(void){...} 不合法C,并且(正如其他人指出的那样)'^'不是C中的指数运算符。
You are trying to solve a 2nd-order differential equation, which is not as simple as it looks. One basic family of solvers is the Runge-Kutta family. Google for more information on derivation, how to use, etc.

Many other solvers exist as well, each optimized for a different set of equation characteristics.

BTW, your function double main(void) {...} is not legal C, and (as someone else has pointed out) '^' is not the exponentiation operator in C.


这篇关于欧拉谐振子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆