Download presentation
Presentation is loading. Please wait.
1
Performing a Computer Simulation using C++
2
Structure of Presentation
Description of Simulation
3
Structure of Presentation
Description of Simulation Results of Simulation
4
Structure of Presentation
Description of Simulation Results of Simulation Overview of C++
5
Structure of Presentation
Description of Simulation What is being simulated Results of Simulation Overview of C++
6
Structure of Presentation
Description of Simulation What is being simulated What is the algorithm Results of Simulation Overview of C++
7
Description of Simulation
8
Description of Simulation
What is being simulated?
9
Description of Simulation
What is being simulated? One-dimensional Lattice of masses on springs.
10
Description of Simulation
What is being simulated? One-dimensional Lattice of masses on springs.
11
Description of Simulation
What is being simulated? One-dimensional Lattice of masses on springs.
21
Comparison of Quadratic Potential
And Toda Potential
22
Quadratic Potential We expect the energy to stay in the initial modes.
23
Quadratic Potential We expect the energy to stay in the initial modes. Toda Potential We expect the energy to migrate into all modes.
24
Surprising result discovered by FPU:
Energy periodically migrates BACK into the initial modes. Toda Potential We expect the energy to migrate into all modes.
25
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.
26
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.
27
Comparison of Quadratic Potential
And Toda Potential
28
Quadratic Potential Good to test that our algorithm works.
29
Quadratic Potential Good to test that our algorithm works. Toda Potential Try to reproduce the periodic energy migration.
30
Description of Simulation
What is the algorithm?
31
Description of Simulation
What is the algorithm? BAD approach: Euler’s method
32
BAD approach: Euler’s method
33
BAD approach: Euler’s method
•Energy diverges
34
BAD approach: Euler’s method
•Energy diverges •Takes a long time to run
35
GOOD approach: Hessian matrix method
36
GOOD approach: Hessian matrix method
37
GOOD approach: Hessian matrix method
38
GOOD approach: Hessian matrix method
39
GOOD approach: Hessian matrix method
40
GOOD approach: Hessian matrix method
41
GOOD approach: Hessian matrix method
•Energy doesn’t diverge
42
GOOD approach: Hessian matrix method
•Energy doesn’t diverge •Much faster to run
43
GOOD approach: Hessian matrix method
44
GOOD approach: Hessian matrix method
45
Review of Algorithm
46
Results of Simulation
47
Results of Simulation Quadratic Potential (Linear Force)
Algorithm is fast and stable
48
Results of Simulation Quadratic Potential (Linear Force)
Algorithm is fast and stable Energy remains in initial modes
49
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
50
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
51
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)
52
Quick overview of C++
53
Quick overview of C++ Object-oriented: Severe encapsulation
54
Quick overview of C++ Object-oriented: Severe encapsulation
Heavily type-safe
55
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
56
Quick overview of C++ Object-oriented: Severe encapsulation
Heavily type-safe: what does it mean?
57
Quick overview of C++ Object-oriented: Severe encapsulation
Heavily type-safe: what does it mean? •Every token is of a certain “type”
58
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.
59
Quick overview of C++ Object-oriented: Severe encapsulation
Inheritance: derive new types from old types
60
Quick overview of C++ Object-oriented: Severe encapsulation
Inheritance: derive new types from old types Almost no risk of introducing bugs into old functionality
61
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
62
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
63
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”
64
Quick overview of C++ Object-oriented: Severe encapsulation
Heavily type-safe:
65
Quick overview of C++ Object-oriented: Severe encapsulation
Heavily type-safe: Programmer is careful to use exactly the right types for the job
66
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.
67
Quick overview of C++ Object-oriented: Severe encapsulation
Programming consists of creating types. Once they are created, they do their job automatically.
68
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.
69
Quick overview of C++ The “main” loop usually consists of creating one or two objects, that’s all.
70
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.
71
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.
72
Quick overview of C++ Disadvantages: Takes a long time to program.
73
Quick overview of C++ Using the MatLab C++ library:
74
Quick overview of C++ Using the MatLab C++ library:
Matlab is a “structured” programming environment.
75
Quick overview of C++ Using the MatLab C++ library:
Matlab is a “structured” programming environment. C++ is an “object-oriented” programming environment.
76
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.
77
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.
78
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.
79
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.
80
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.
81
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.
82
Further Work to be Done:
Add periodic boundary conditions Observe solitons
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.