Performing a Computer Simulation using C++
Structure of Presentation Description of Simulation
Structure of Presentation Description of Simulation Results of Simulation
Structure of Presentation Description of Simulation Results of Simulation Overview of C++
Structure of Presentation Description of Simulation What is being simulated Results of Simulation Overview of C++
Structure of Presentation Description of Simulation What is being simulated What is the algorithm Results of Simulation Overview of C++
Description of Simulation
Description of Simulation What is being simulated?
Description of Simulation What is being simulated? One-dimensional Lattice of masses on springs.
Description of Simulation What is being simulated? One-dimensional Lattice of masses on springs.
Description of Simulation What is being simulated? One-dimensional Lattice of masses on springs.
Comparison of Quadratic Potential And Toda Potential
Quadratic Potential We expect the energy to stay in the initial modes.
Quadratic Potential We expect the energy to stay in the initial modes. Toda Potential We expect the energy to migrate into all modes.
Surprising result discovered by FPU: Energy periodically migrates BACK into the initial modes. Toda Potential We expect the energy to migrate into all modes.
Surprising result discovered by FPU: Energy periodically migrates BACK into the initial modes. Surprising result #2: Solitons, particle-like waves that maintain their shape forever without dispersing or breaking up. Toda Potential We expect the energy to migrate into all modes.
Surprising result #2: Solitons, particle-like waves that maintain their shape forever without dispersing or breaking up. Periodic boundary conditions required. I won’t demonstrate these.
Comparison of Quadratic Potential And Toda Potential
Quadratic Potential Good to test that our algorithm works.
Quadratic Potential Good to test that our algorithm works. Toda Potential Try to reproduce the periodic energy migration.
Description of Simulation What is the algorithm?
Description of Simulation What is the algorithm? BAD approach: Euler’s method
BAD approach: Euler’s method
BAD approach: Euler’s method •Energy diverges
BAD approach: Euler’s method •Energy diverges •Takes a long time to run
GOOD approach: Hessian matrix method
GOOD approach: Hessian matrix method
GOOD approach: Hessian matrix method
GOOD approach: Hessian matrix method
GOOD approach: Hessian matrix method
GOOD approach: Hessian matrix method
GOOD approach: Hessian matrix method •Energy doesn’t diverge
GOOD approach: Hessian matrix method •Energy doesn’t diverge •Much faster to run
GOOD approach: Hessian matrix method
GOOD approach: Hessian matrix method
Review of Algorithm
Results of Simulation
Results of Simulation Quadratic Potential (Linear Force) Algorithm is fast and stable
Results of Simulation Quadratic Potential (Linear Force) Algorithm is fast and stable Energy remains in initial modes
Results of Simulation Quadratic Potential (Linear Force) Algorithm is fast and stable Energy remains in initial modes Toda Potential (Nonlinear Force) Algorithm is stable if the nonlinear constant is not too large
Results of Simulation Quadratic Potential (Linear Force) Algorithm is fast and stable Energy remains in initial modes Toda Potential (Nonlinear Force) Algorithm is stable if the nonlinear constant is not too large Takes too long to see energy migrate to other modes
Results of Simulation Quadratic Potential (Linear Force) Algorithm is fast and stable Energy remains in initial modes Toda Potential (Nonlinear Force) Algorithm is stable if the nonlinear constant is not too large Takes too long to see energy migrate to other modes For just the right combination, we see the energy migrate back to the first mode (m=k=b=1, dt=.01, 8 particles, 5 second simulation)
Quick overview of C++
Quick overview of C++ Object-oriented: Severe encapsulation
Quick overview of C++ Object-oriented: Severe encapsulation Heavily type-safe
Quick overview of C++ Object-oriented: Severe encapsulation Heavily type-safe Most errors caught by compiler… once it compiles, it will probably run “fairly” well
Quick overview of C++ Object-oriented: Severe encapsulation Heavily type-safe: what does it mean?
Quick overview of C++ Object-oriented: Severe encapsulation Heavily type-safe: what does it mean? •Every token is of a certain “type”
Quick overview of C++ Object-oriented: Severe encapsulation Heavily type-safe: what does it mean? • Easy debugging: debug just the type itself, not the program.
Quick overview of C++ Object-oriented: Severe encapsulation Inheritance: derive new types from old types
Quick overview of C++ Object-oriented: Severe encapsulation Inheritance: derive new types from old types Almost no risk of introducing bugs into old functionality
Quick overview of C++ Object-oriented: Severe encapsulation Inheritance: derive new types from old types Almost no risk of introducing bugs into base type’s functionality Derived type can be very small and easy to understand
Quick overview of C++ Object-oriented: Severe encapsulation Inheritance: derive new types from old types Almost no risk of introducing bugs into base type’s functionality Derived type can be very small and easy to understand Polymorphism: derived type can “override” key behavior of base type
Example: Shape Base type: SHAPE Derived Type: Circle Circle overrides function “draw” Derived Type: Polygon Derived Type: Square Square overrides function “draw” Derived Type: Triangle Triangle overrides function “draw”
Quick overview of C++ Object-oriented: Severe encapsulation Heavily type-safe:
Quick overview of C++ Object-oriented: Severe encapsulation Heavily type-safe: Programmer is careful to use exactly the right types for the job
Quick overview of C++ Object-oriented: Severe encapsulation Heavily type-safe: Programmer is careful to use exactly the right types for the job Programming consists of creating types. Once they are created, they do their job automatically.
Quick overview of C++ Object-oriented: Severe encapsulation Programming consists of creating types. Once they are created, they do their job automatically.
Quick overview of C++ Object-oriented: Severe encapsulation Programming consists of creating types. Once they are created, they do their job automatically. This allows for highly extensible, error-free code.
Quick overview of C++ The “main” loop usually consists of creating one or two objects, that’s all.
Quick overview of C++ The “main” loop usually consists of creating one or two objects, that’s all. It is a completely different way of programming than “structured” programming.
Quick overview of C++ The “main” loop usually consists of creating one or two objects, that’s all. It is a completely different way of programming than “structured” programming. The concept of “flow of control” is strictly avoided except at the lowest levels.
Quick overview of C++ Disadvantages: Takes a long time to program.
Quick overview of C++ Using the MatLab C++ library:
Quick overview of C++ Using the MatLab C++ library: Matlab is a “structured” programming environment.
Quick overview of C++ Using the MatLab C++ library: Matlab is a “structured” programming environment. C++ is an “object-oriented” programming environment.
Quick overview of C++ Using the MatLab C++ library: Matlab is a “structured” programming environment. C++ is an “object-oriented” programming environment. It is hard to make a library that works well for both MatLab and for C++ programmers.
Quick overview of C++ Using the MatLab C++ library: It is hard to make a library that works well for both MatLab and for C++ programmers.
Quick overview of C++ Using the MatLab C++ library: It is hard to make a library that works well for both MatLab and for C++ programmers. MatLab chose to create a simple interface, without any derived objects.
Quick overview of C++ Using the MatLab C++ library: It is hard to make a library that works well for both MatLab and for C++ programmers. MatLab chose to create a simple interface, without any derived objects. This allows MatLab programmers to use “structured” programming in C++, without utilizing object-oriented programming.
Quick overview of C++ Using the MatLab C++ library: It is hard to make a library that works well for both MatLab and for C++ programmers. MatLab chose to create a simple interface, without any derived objects. This allows C++ programmers to create their own object-oriented libraries to fully utilize object-oriented programming.
Quick overview of C++ Using the MatLab C++ library: My code is basically structural. It would take a long time to develop an effective object-oriented library using the simple base classes provided by MatLab.
Further Work to be Done: Add periodic boundary conditions Observe solitons