Giter Club home page Giter Club logo

discrete-universe-mathematica's Introduction

Energy Conservation in Discrete Universe Simulation

Project Description

This Mathematica simulation is an agent-based universe in which each agent reacts to each other according to Newton's law of universal gravitation. Everything is discrete, including time.

The questions of interest are:

  • How does the initial velocity of one planet affect its trajectory around the sun? How about mass? Location?
  • By calculating the gravitational potential (also known as Newtonian potential) energy and the kinetic energy, we will investigate whether the total energy can be conserved in a discrete universe.

Theoretical Framework

First, because of the complexity of simulating the entire solar system, only the sun and one planet are included in this model. The sun is set to be initially located at the origin. This origin position (xp, yp), the initial velocities (xv, yv), and the mass of the planet can be manipulated in the model. Each agent will interact with each other according to Newton's law of universal gravitation:

F = G * (m1 * m2) / r2

where:

F is the force between the masses,

G is the gravitational constant,

m1 is the first mass,

m2 is the second mass, and

r is the distance between the centers of the masses.

In this equation, r is calculated as โˆš((xp1 - xp2)2 + (yp1 - yp2)2)

After that, we can apply the Newton's law of motion: F = m * a to derive the acceleration vector of each sun. Since we have the initial velocity (vt), we can obtain the velocity (v0) after each unit of time (potentially every second) using the equation vt = v0 + at. The suns will move accordingly to their velocity vectors (xv, yv) and arrive at new positions. Since our universe is discreet, we can only report the positions of all the suns discreetly at each given time. At each given time and velocity, we can calculate the total energy of each sun using the gravitational potential energy formula and kinetic energy formula:

U = -m * โˆ‘ [G * (M / r)]

Ek = 1/2 * m * v2

The total energy of the entire universe is then calculated and presented in a graph.

Usage

By selecting the initial values for: location (distance of the planet from the sun), mass (in this simulation, we will assume the sun and the planet have equal masses), and velocity (initial velocity of the planet), we can look at how the planet would orbit around the sun.

alt-text

discrete-universe-mathematica's People

Contributors

dtmlinh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.