欧拉谐振子

编程入门 行业动态 更新时间:2024-10-19 15:38:29
本文介绍了欧拉谐振子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好, 我有一个谐波振荡器定义: 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.

更多推荐

欧拉谐振子

本文发布于:2023-11-29 20:42:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647577.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:谐振子   欧拉

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!