Using your work from the previousproblems, you can now simulate thetrajectories of the interact… Show more… Show more is exerted by the Sun and the Earth.The force from the Moon on the Earthis Gm m .. FEM (t) = _+tMr… Show more… Show more Note that, for instance, rE (t + 1)means “the position of the Earthat time step t+1”. In … Show more… Show more Optional To make the plot prettier youcan do the tollowing (optional): Set theaspect ratio to equal with … Show more… Show moremain.py <—- this is the code I have so far# add necessary importsimport numpy as npimport mathimport matplotlib.pyplot as plt# constantsG = 4*np.pi**2mass = { ‘sun’: 1.0, ‘earth’: 3.0034e-6, ‘moon’: 3.6923e-7}r0 = { ‘sun’: np.array([0,0,0]), ‘earth’: np.array([9.978977040419635E-01, 6.586825681892025E-02, -6.320430920521123E-06]), ‘moon’: np.array([9.956768547953816E-01, 6.676030485840675E-02, 1.641093070596718E-04]) }v0 = { ‘sun’: np.array([0,0,0]), ‘earth’: np.array([-4.70015711e-01, 6.25165839e+00, -3.40817831e-04]), ‘moon’: np.array([-0.55065949, 6.03534661, 0.01111456])}# functionsdef F_gravity(ri, rj, mi, mj):rij = ri-rjlength = np.sqrt(np.dot(rij,rij))dirNorm = rij / (rij**2).sum()**0.5return (-G*mi*mj/(length**2))*dirNormprint(F_gravity(r0[‘moon’],r0[‘earth’],mass[‘moon’],mass[‘earth’]))def F_ES(rE):return -F_gravity(r0[“sun”],rE,mass[“earth”],mass[“sun”])def integrate_earth(tmax,dt=1e-3):steps = np.arange(0,tmax,dt)r_values=[]r=r0[“earth”].copy()v =v0[“earth”].copy()m_inv = 1/(mass[“earth”])r_values.append(r.copy())for t in steps: r +=v*dt v+=m_inv*F_ES(r.copy())*dt r_values.append(r.copy())return np.array(r_values)if __name__ == “__main__”:positions = integrate_earth(1)array =(positions)plt.plot(array[:,0],array[:,1])plt.xlabel(“x (AU)”)plt.ylabel(“y (AU)”)plt.savefig(“orbit_earth_only.png”)plt.show()Computer ScienceEngineering & TechnologyPython Programming CS/IS 112
solved : Using your work from the previousproblems, you can now simu
How it works
- Paste your instructions in the instructions box. You can also attach an instructions file
- Select the writer category, deadline, education level and review the instructionsÂ
- Make a payment for the order to be assigned to a writer
- Â Download the paper after the writer uploads itÂ
Will the writer plagiarize my essay?
You will get a plagiarism-free paper and you can get an originality report upon request.
Is this service safe?
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
LET THE PROFESSIONALS WRITE YOUR PAPER!