Jump to content

File:3bodyproblem.gif

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia
    Original file (780 × 246 pixels, file size: 1.56 MB, MIME type: image/gif, looped, 201 frames)

    Summary

    Description
    English: A system of 3 bodies interacting gravitationally is (famously) chaotic. A system of 3 bodies interacting elastically isn't. Time in this animations is increasing from top right to down left along the diagonal, to show the evolution of the two systems.
    Date
    Source https://twitter.com/j_bertolotti/status/1044947721696808961
    Author Jacopo Bertolotti
    Permission
    (Reusing this file)
    https://twitter.com/j_bertolotti/status/1030470604418428929

    Mathematica 11.0 code

    (*Staring positions in a triangle*)
    x10 = -1;
    y10 = -1;
    x20 = 1;
    y20 = -1;
    x30 = 1;
    y30 = 1;
    (*Initial total momentum is zero, so the center of mass does not \
    drift away*)
    vx10 = 0.2;
    vy10 = 0;
    vx20 = -0.1;
    vy20 = 0;
    vx30 = 0;
    vy30 = -0.1;
    (*max time the system evolves (in arbitrary units)*)
    T = 40;
    (*All three bodies have the same mass*)
    m1 = 1;
    m2 = 1;
    m3 = 1;
    (*Setting up of the equations copied from \
    http://demonstrations.wolfram.com/PlanarThreeBodyProblem/
    There are more elegant and compact ways of doing this, but I wasn't \
    interested in optimizing the code.*)
    nds = NDSolve[
       {x1'[t] == vx1[t], y1'[t] == vy1[t],
        x2'[t] == vx2[t], y2'[t] == vy2[t],
        x3'[t] == vx3[t], y3'[t] == vy3[t],
        m1 vx1'[t] == -((
           m1 m2 (x1[t] - 
              x2[t]))/((x1[t] - x2[t])^2 + (y1[t] - y2[t])^2)^(3/2)) - (
          m1 m3 (x1[t] - x3[t]))/((x1[t] - x3[t])^2 + (y1[t] - y3[t])^2)^(
          3/2), m1 vy1'[t] == -((
           m1 m2 (y1[t] - 
              y2[t]))/((x1[t] - x2[t])^2 + (y1[t] - y2[t])^2)^(3/2)) - (
          m1 m3 (y1[t] - y3[t]))/((x1[t] - x3[t])^2 + (y1[t] - y3[t])^2)^(
          3/2), m2 vx2'[t] == (
          m1 m2 (x1[t] - x2[t]))/((x1[t] - x2[t])^2 + (y1[t] - y2[t])^2)^(
          3/2) - (m2 m3 (x2[t] - 
             x3[t]))/((x2[t] - x3[t])^2 + (y2[t] - y3[t])^2)^(3/2), 
        m2 vy2'[t] == (
          m1 m2 (y1[t] - y2[t]))/((x1[t] - x2[t])^2 + (y1[t] - y2[t])^2)^(
          3/2) - (
          m2 m3 (y2[t] - y3[t]))/((x2[t] - x3[t])^2 + (y2[t] - y3[t])^2)^(
          3/2), m3 vx3'[t] == (
          m1 m3 (x1[t] - x3[t]))/((x1[t] - x3[t])^2 + (y1[t] - y3[t])^2)^(
          3/2) + (m2 m3 (x2[t] - 
             x3[t]))/((x2[t] - x3[t])^2 + (y2[t] - y3[t])^2)^(3/2), 
        m3 vy3'[t] == (
          m1 m3 (y1[t] - y3[t]))/((x1[t] - x3[t])^2 + (y1[t] - y3[t])^2)^(
          3/2) + (m2 m3 (y2[t] - 
             y3[t]))/((x2[t] - x3[t])^2 + (y2[t] - y3[t])^2)^(3/2),
        x1[0] == x10, y1[0] == y10, x2[0] == x20, y2[0] == y20, 
        x3[0] == x30, y3[0] == y30,
        vx1[0] == vx10, vy1[0] == vy10, vx2[0] == vx20, vy2[0] == vy20, 
        vx3[0] == vx30, vy3[0] == vy30},
       {x1, x2, x3, y1, y2, y3, vx1, vx2, vx3, vy1, vy2, vy3}, {t, 0, 
        T}];
    funsToPlot = {{x1[t], y1[t]}, {x2[t], y2[t]}, {x3[t], y3[t]}} /. 
       nds[[1]];
    evo = Table[funsToPlot /. {t -> j}, {t, 0, T, 0.01}];
    dim = Dimensions[evo][[1]];
    (*For the elastic force case I used a Verlet integration, as this \
    case is numerically very stable.*)
    np = 3;
    k0 = 1;
    (*Same initial condition as the gravitational case*)
    
    pos = {{x10, y10}, {x20, y20}, {x30, y30}};
    v0 = {{vx10, vy10}, {vx20, vy20}, {vx30, vy30}};
    acc = Table[
       Sum[If[j == k, 0, -k0 (pos[[j]] - pos[[k]])], {k, 1, np}], {j, 1, 
        np}];
    dt = 0.005;
    posold = pos;
    pos = posold + v0 dt + acc/2 dt^2;
    range = 5;
    
    evoe = Reap[Do[
          acc = 
           Table[Sum[
             If[j == k, 0, -k0 (pos[[j]] - pos[[k]])], {k, 1, np}], {j, 1,
              np}];
          posoldold = posold;
          posold = pos;
          pos = 2 posold - posoldold + acc dt^2;
          Sow[pos];
          , dim];][[2, 1]];
    plots = Table[
       GraphicsRow[{
         Show[
          ListPlot[{evo[[All, 1]][[1 ;; j]], evo[[All, 2]][[1 ;; j]], 
            evo[[All, 3]][[1 ;; j]]}, PlotStyle -> {Purple, Orange, Cyan},
            PlotRange -> {{-range, range}, {-range, range}}, 
           Joined -> True, Axes -> False, 
           PlotLabel -> "Gravitational 3-body problem", 
           LabelStyle -> {Bold, Black}],
          Graphics[{PointSize[0.03], Purple, Point[evo[[All, 1]][[j]]], 
            Orange, Point[evo[[All, 2]][[j]]], Cyan, 
            Point[evo[[All, 3]][[j]]]} , 
           PlotRange -> {{-range, range}, {-range, range}}], 
          ImageSize -> Medium
          ]
         ,
         Show[
          ListPlot[{evoe[[All, 1]][[1 ;; j]], evoe[[All, 2]][[1 ;; j]], 
            evoe[[All, 3]][[1 ;; j]]}, 
           PlotStyle -> {Purple, Orange, Cyan}, 
           PlotRange -> {{-range, range}, {-range, range}}, 
           Joined -> True, Axes -> False, 
           PlotLabel -> "Elastic 3-body problem", 
           LabelStyle -> {Bold, Black}],
          Graphics[{PointSize[0.03], Purple, Point[evoe[[All, 1]][[j]]], 
            Orange, Point[evoe[[All, 2]][[j]]], Cyan, 
            Point[evoe[[All, 3]][[j]]]} , 
           PlotRange -> {{-range, range}, {-range, range}}], 
          ImageSize -> Medium
          ]
         }], {j, 1, dim, 20}];
    ListAnimate[plots]
    

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
    The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

    This file, which was originally posted to https://twitter.com/j_bertolotti/status/1044947721696808961, was reviewed on 19 October 2018 by reviewer Ronhjones, who confirmed that it was available there under the stated license on that date.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    copyright license<\/a>"}},"text\/plain":{"en":{"":"copyright license"}}},"{\"value\":{\"entity-type\":\"item\",\"numeric-id\":6938433,\"id\":\"Q6938433\"},\"type\":\"wikibase-entityid\"}":{"text\/html":{"en":{"P275":"Creative Commons CC0 License<\/a>"}},"text\/plain":{"en":{"P275":"Creative Commons CC0 License"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P275 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">
    inception<\/a>"}},"text\/plain":{"en":{"":"inception"}}},"{\"value\":{\"time\":\"+2018-09-26T00:00:00Z\",\"timezone\":0,\"before\":0,\"after\":0,\"precision\":11,\"calendarmodel\":\"http:\\\/\\\/www.wikidata.org\\\/entity\\\/Q1985727\"},\"type\":\"time\"}":{"text\/html":{"en":{"P571":"26 September 2018"}},"text\/plain":{"en":{"P571":"26 September 2018"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P571 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">

    26 September 2018

    media type<\/a>"}},"text\/plain":{"en":{"":"media type"}}},"{\"value\":\"image\\\/gif\",\"type\":\"string\"}":{"text\/html":{"en":{"P1163":"image\/gif"}},"text\/plain":{"en":{"P1163":"image\/gif"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P1163 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">

    image/gif

    checksum<\/a>"}},"text\/plain":{"en":{"":"checksum"}}},"{\"value\":\"de640cb31cd852c54117eae84e22eae4a9a9f981\",\"type\":\"string\"}":{"text\/html":{"en":{"P4092":"de640cb31cd852c54117eae84e22eae4a9a9f981"}},"text\/plain":{"en":{"P4092":"de640cb31cd852c54117eae84e22eae4a9a9f981"}}},"{\"value\":{\"entity-type\":\"property\",\"numeric-id\":459,\"id\":\"P459\"},\"type\":\"wikibase-entityid\"}":{"text\/html":{"en":{"":"determination method or standard<\/a>"}},"text\/plain":{"en":{"":"determination method or standard"}}},"{\"value\":{\"entity-type\":\"item\",\"numeric-id\":13414952,\"id\":\"Q13414952\"},\"type\":\"wikibase-entityid\"}":{"text\/html":{"en":{"P459":"SHA-1<\/a>"}},"text\/plain":{"en":{"P459":"SHA-1"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P4092 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">

    de640cb31cd852c54117eae84e22eae4a9a9f981

    data size<\/a>"}},"text\/plain":{"en":{"":"data size"}}},"{\"value\":{\"amount\":\"+1634680\",\"unit\":\"http:\\\/\\\/www.wikidata.org\\\/entity\\\/Q8799\"},\"type\":\"quantity\"}":{"text\/html":{"en":{"P3575":"1,634,680 byte<\/span>"}},"text\/plain":{"en":{"P3575":"1,634,680 byte"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P3575 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">

    1,634,680 byte

    height<\/a>"}},"text\/plain":{"en":{"":"height"}}},"{\"value\":{\"amount\":\"+246\",\"unit\":\"http:\\\/\\\/www.wikidata.org\\\/entity\\\/Q355198\"},\"type\":\"quantity\"}":{"text\/html":{"en":{"P2048":"246 pixel<\/span>"}},"text\/plain":{"en":{"P2048":"246 pixel"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P2048 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">

    246 pixel

    width<\/a>"}},"text\/plain":{"en":{"":"width"}}},"{\"value\":{\"amount\":\"+780\",\"unit\":\"http:\\\/\\\/www.wikidata.org\\\/entity\\\/Q355198\"},\"type\":\"quantity\"}":{"text\/html":{"en":{"P2049":"780 pixel<\/span>"}},"text\/plain":{"en":{"P2049":"780 pixel"}}}}" class="wbmi-entityview-statementsGroup wbmi-entityview-statementsGroup-P2049 oo-ui-layout oo-ui-panelLayout oo-ui-panelLayout-framed">

    780 pixel

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current14:03, 26 September 2018Thumbnail for version as of 14:03, 26 September 2018780 × 246 (1.56 MB)BertoUser created page with UploadWizard

    The following page uses this file:

    Global file usage

    The following other wikis use this file:

    Metadata