This is the web version of EJS interface
EJS version 4.2.7
  1. Title=Earth and Moon
  2. Author=Francisco Esquembre Universidad de Murcia
  3. Keywords=Two-body problem, Gravitation
  4. CaptureTools=false
  5. DataTools=false
  6. LanguageTools=false
  7. EmersionSupport=false
  8. UseInterpreter=true
  9. AuxiliaryFiles=_data/earthrot.gif;_data/moonrot.gif;_data/reset.gif;_data/pause.gif;_data/play.gif;
  10. DetectedFiles=_data/earthrot.gif;_data/moonrot.gif;_data/pause.gif;_data/play.gif;_data/reset.gif;
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension

    Initial Conditions

    // ----- positions double semiaxis = 3.84e8; xE = - massMoon*semiaxis/(massEarth+massMoon); yE = 0.0; xM = massEarth*semiaxis/(massEarth+massMoon); yM = 0.0; // ----- velocities double epsilon = 0.0550; double K = G*massEarth*massMoon; double mu = massEarth*massMoon/(massEarth+massMoon); double velEM = Math.sqrt (((1-epsilon*epsilon)*K)/(mu*semiaxis)); vxE = 0.0; vyE = - massMoon*velEM/(massEarth+massMoon); vxM = 0.0; vyM = massEarth*velEM/(massEarth+massMoon);
    Commet:T

    Equations

    Indep. Var. Increment
    d xE /dtime=vxE
    d yE /dtime=vyE
    d xM /dtime=vxM
    d yM /dtime=vyM
    d vxE /dtime=forceX(xE,yE,xM,yM)/massEarth
    d vyE /dtime=forceY(xE,yE,xM,yM)/massEarth
    d vxM /dtime=forceX(xM,yM,xE,yE)/massMoon
    d vyM /dtime=forceY(xM,yM,xE,yE)/massMoon
    SolverMidPoint
    Newton second law
    hours = time/3600.0; days = (int) (hours / 24.0); hours = hours - days*24.0; // % 24; if ((yMprevious<0.0) && (yM>=0.0)) { time = dt; cycle++; periodDays = days; periodHours = hours; } yMprevious = yM;
    Commet:Compute the period and cycle
    showPlanets = ! showOrbits;

    Forces

    public double forceX (double x1, double y1, double x2, double y2) { double d2 = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1); return G*massEarth*massMoon*(x2-x1)/Math.pow (d2,1.5); } public double forceY (double x1, double y1, double x2, double y2) { double d2 = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1); return G*massEarth*massMoon*(y2-y1)/Math.pow (d2,1.5); }
    Commet:Universal gravitational law
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    title=Earth and Moon
    layout=border
    visible=true
    location="353,116"
    size="526,418"
    position=west
    layout=border
    background=DARKGRAY
    position=north
    layout=grid:0,1,0,0
    foreground=GREEN
    image="_data/play.gif"
    enabled=_isPaused
    action=_play()
    size="90,35"
    image="_data/pause.gif"
    enabled=_isPlaying
    action=_pause()
    size="90,35"
    image="_data/reset.gif"
    action=_reset()
    size="90,35"
    variable=showOrbits
    selected=false
    text= Orbits
    position=south
    layout=grid:0,1,0,0
    background=DARKGRAY
    variable=cycle
    format=Cycle = #
    editable=false
    foreground=255,128,0
    variable=days
    format=Days = #
    editable=false
    foreground=255,128,0
    text=Last cycle
    alignment=center
    foreground=CYAN
    variable=periodDays
    format=Days = 0
    editable=false
    foreground=255,128,0
    variable=periodHours
    format=Hours = 0.0
    editable=false
    foreground=255,128,0
    position=center
    autoscaleX=false
    autoscaleY=false
    minimumX=minimum
    maximumX=maximum
    minimumY=minimum
    maximumY=maximum
    background=black
    x=xE
    y=yE
    sizex=radiusEarth
    sizey=radiusEarth
    scalex=25
    scaley=25
    visible=showPlanets
    enabled=false
    image="_data/earthrot.gif"
    elementposition=CENTERED
    x=xM
    y=yM
    sizex=radiusMoon
    sizey=radiusMoon
    scalex=50
    scaley=50
    visible=showPlanets
    enabled=false
    image="_data/moonrot.gif"
    elementposition=CENTERED
    x=xE
    y=yE
    visible=showOrbits
    maxpoints=traceLength
    skippoints=10
    connected=true
    color=blue
    x=xM
    y=yM
    visible=showOrbits
    maxpoints=traceLength
    skippoints=10
    connected=true
    color=gray