Skip to content

Commit

Permalink
Implemented eliptical regression test. It's very close to machine pre…
Browse files Browse the repository at this point in the history
…cision
  • Loading branch information
Maxwell-Rosen committed Nov 28, 2023
1 parent 153e2da commit 93e9128
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added figures/elliptical_orbit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions ias15PDE.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ def calculateNodePositions(Bx, By, xi, yi, func: callable, gunc: callable, dt, h
By[6])))))))
return xh, yh

def calculateNewPosition(B, xi, ti, func: callable, gunc: callable, dt):
newPosition = calculateNodePositions(B, xi, ti, func, gunc, dt, hp = np.array([1]))
def calculateNewPosition(Bx, By, xi, yi, func: callable, gunc: callable, dt):
newPosition = calculateNodePositions(Bx, By, xi, yi, func, gunc, dt, hp = np.array([1]))
return newPosition

def calculateDerivatives(func: callable, gunc: callable, x, t):
def calculateDerivatives(x, y, func: callable, gunc: callable):
Fx = np.zeros(len(x))
Fy = np.zeros(len(x))
for i in range(len(x)):
Fy[i] = func(x[i], t[i])
Fx[i] = gunc(x[i], t[i])
Fy[i] = func(x[i], y[i])
Fx[i] = gunc(x[i], y[i])
return Fx, Fy

def calculateB_xy(Gx, Gy):
Expand Down
47 changes: 38 additions & 9 deletions regression_elipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,41 @@
x0 = 1
y0 = 0

dt = 1
Bx = np.zeros(7)
By = np.zeros(7)
for i in range(12):
xh, yh = ias15.calculateNodePositions(Bx, By, x0, y0, dxds, dyds, dt)
Fx, Fy = ias15.calculateDerivatives(dxds, dyds, xh, yh)
Gx, Gy = ias15.calculateGFromF_xy(Fx, Fy)
Bx, By = ias15.calculateB_xy(Gx, Gy)

ds = .001
s_final = np.pi*2
nSteps = int(s_final/ds)
s = np.linspace(0,s_final,nSteps+1, endpoint=True)
x = np.zeros(nSteps+1)
y = np.zeros(nSteps+1)
x[0] = x0
y[0] = y0
Bxi = np.zeros(7)
Byi = np.zeros(7)
for i in range(1,nSteps+1):
x[i], y[i], Bxf, Byf = ias15.push(dyds, dxds, x[i-1], y[i-1], ds, Bxi, Byi)
Bxi = Bxf
Byi = Byf

radius = np.sqrt(x**2 + y**2)

fig = plt.figure()
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)

ax1.plot(x,y,'r.')
ax1.set_xlim(-1.5,1.5)
ax1.set_ylim(-1.5,1.5)
ax1.set_title("Elliptical Orbit")
ax1.set_xlabel("x")
ax1.set_ylabel("y")
#Set aspect ratio to be square
ax1.set_aspect('equal')
ax1.grid()

ax2.plot(s,radius-1,'r.')
ax2.set_title("Radius - 1")
ax2.set_xlabel("s")
ax2.set_ylabel("radius - 1")
ax2.grid()
plt.savefig("figures/elliptical_orbit.png")
plt.show()

0 comments on commit 93e9128

Please sign in to comment.