# PHY283 Scientific Modelling Week 1Slide 1 Physics Simulations In this lab class we will be creating Simulations of Gravitational Systems. This will involve.

## Presentation on theme: "PHY283 Scientific Modelling Week 1Slide 1 Physics Simulations In this lab class we will be creating Simulations of Gravitational Systems. This will involve."— Presentation transcript:

PHY283 Scientific Modelling Week 1Slide 1 Physics Simulations In this lab class we will be creating Simulations of Gravitational Systems. This will involve several steps: –Analysis of Problem –Design of Appropriate Classes Member Variables Constructors Methods etc. –Code should be reusable –Testing Code

PHY283 Scientific Modelling Week 1Slide 2 Previous Work Assume understood and completed 281 –Need to be able create classes –Graphics –Mathematical Calculations…

PHY283 Scientific Modelling Week 1Slide 3 Grading 100% Course Work –divided into 5 weekly projects and final report on project. –Will need to document all code. –Please back up all of your code onto floppy disks

PHY283 Scientific Modelling Week 1Slide 4 Course Outline Week 1: –Class Design ThreeVector Class –Class Design of MassiveObject Class –Class Design of GravitationalForceField –Create ThreeVector Class with following properties dotProduct set add subtract cross product print get magnitude scalar multiplication

PHY283 Scientific Modelling Week 1Slide 5 Course Outline Week 2: –Physics Simulation issues –Simulate Massive Object on Earths Surface in 2d Week 3 –Simulation of 2D orbiting bodies –Simulation of object in tunnel through center of earth Week 4 –Simulate 3 bodies in 3D –simulate N bodies in 3D Week 5: Flashy Graphics..

PHY283 Scientific Modelling Week 1Slide 6 Gravitation Force on a massive object depends on all the massive objects in the system. What properties does a Gravitational Object have?

PHY283 Scientific Modelling Week 1Slide 7 Potential and Force Given a Potential Field G(x,y,z) the force is given by the three dimensional vector derivative Requires mathematical calculation of the derivatives of a function We can create a force field class instead.

PHY283 Scientific Modelling Week 1Slide 8 Class Design Class Design ThreeVector Class Class Design of MassiveObject Class Class Design of GravitationalForceField Work together on what are the properties required. Will need to write up your design in your log book.

PHY283 Scientific Modelling Week 1Slide 9 Implementation of Vector Class Member Variables should be private –allows you to change implementation without changing user code –Access all variables via public methods Document your code. Write a class to test your code –What are appropriate tests?

PHY283 Scientific Modelling Week 1Slide 10 Example of Documented Code /** * An example of documented code * @author Iain Bertram * @version 1.0 */ public class Sample { private double myVariable; /** * The Default Constructor, set to zero * */ public Sample(){ this.myVariable = 0.0; } /** * * Constructor that sets a value * */ public Sample(double setValue){ this.myVariable = setValue; }

PHY283 Scientific Modelling Week 1Slide 11 Continued /* * * Method to obtain the value stored in the class */ public double getVariable(){double arg=this.myVariable; return arg;} /* * Method to set variable * */ public void setVariable(double setValue){ this.myVariable = setValue; } /* * Method to print Variable */ public void print(){ System.out.print("The variable is: "+this.myVariable+"\n"); }

Download ppt "PHY283 Scientific Modelling Week 1Slide 1 Physics Simulations In this lab class we will be creating Simulations of Gravitational Systems. This will involve."

Similar presentations