当我尝试链接我的代码时,我得到了一个链接错误(未定义的引用),但我找不出原因。
I am linking using the following command:
mpic++ -Wl,-V main.o Particle.o Particle_forces.o User_input.o output.o time_step_Gear_Verlet.o Verlet_variables.o -o DEM.exe -Lboost_mpi.a -Lboost_serialization.a
我得到的错误告诉我“main.cpp中的步骤(...)函数是未定义的。
main()的So...the代码看
下面是我的Verlet函数的代码,将从我的主脚本中调用。
% verlet.m
% uses the verlet step algorithm to integrate the simple harmonic
% oscillator.
% stepsize h, for a second-order ODE
function vout = verlet(vinverletx,h,params)
% vin is the particle vector (xn,yn)
x0 = vinverletx(1);
x1 = vinverletx(2);
% find the verlet
我使用了以下公式来实现velocity verlet算法(在这里用一种伪代码编写):
time+=timeStep;
newPosition+=timeStep*(velocity+acceleration*timeStep*0.5);
newA = Force/mass, force is a function of newPosition
v+= 0.5*timeStep*(newA-acceleration);
这不管用!newA-acceleration非常小。我用错公式了吗?或者速度verlet算法对于小的timeSteps (我使用的是2秒)不能很好地工作?
(如果这个放错了地
我正在尝试使用Vertel算法求解微分方程,但我无法摆脱这个错误。有什么建议吗? def Vertel(dt, x0, v0, t, tstop, pravastrana, M=1):
i = 0
x = x0
v = v0
k = 1 # Spring constant
m = 1
while t <= tstop:
a = -(k/m)* x[i]
if i == 0:
v_next = v[i] + a* dt
x_next = x[i] + v_next* dt
我们用Verlet方法移动图基。但它只移动了一次而不是连续地移动一次。更新土耳其位置的代码在Update()方法中,因此它应该对每一个帧进行修整。但它只运行了一次。
此外,我们在更新方法中放置了三次更新土耳其线渲染对象位置的代码,而土耳其的新位置似乎只移动了一次。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GenerateTurkeys : MonoBehaviour
{
public LineRenderer lineRend
这是一个家庭作业问题(不要复制,复制不智能):我们需要使用Verlet方法在unity 2d中绘制一个2d火鸡来更新顶点的位置。然而,我们不知道追查土耳其的相关力量。这是一张火鸡的照片。有什么窍门吗?
下面是我们开始的代码:
public class GenerateTurkeys : MonoBehaviour
{
LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
// Start is called before the first frame update
我正在尝试模拟地球围绕太阳的运动。(This is the task I am trying to do)这就是我到目前为止想出的 import numpy as np
import matplotlib.pyplot as plt
#Set parameters:
N = 365 # Earth days in a year
dt = 1.00/N # Time Step: Fractions of a year - 1 Earth day (i.e. 1/365)
mu = 4 * np.pi**2
我的程序(应该是)解出两个物体的运动方程,但是结果是粒子的运行方式,我找不到误差在哪里。
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
DIM = 2
N = 2
ITER = 1000
def acc(r, v, a):
for i in range(N - 1):
for j in range(i+1, N):
r2 = 0.0
rij = [0.0, 0.0]
for
我试图写一个代码来解决n-body问题,当我使用一个包含所有body的数组,而不是单独使用不同的body时,我遇到了麻烦。我目前不知道我的代码中出了什么问题,但是当我在y的函数中为任何主体绘制x时,我得到了一条直线,这显然是不正确的。
这是我当前的代码:
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <fstream>
#define h 10000.0
#define N 3
#define G 6.67384*pow(10.0,-11)
using n