############################################ #### SMN Particle Simulator v3.2 (beta} #### ############################################ by John Ringland (2006-01-18) -- modified 2006-02-01 restructuring of the code -- modified 2006-02-05 restructuring of the code and added 'zoom' functionality This program should run on all DOS or Windows based systems. SMN is a new system modeling methodology that allows for the realistic simulation of general systems. This program is a simple illustration of the core functionality of SMN. It implements a context for systems of particles to interact in space via a gravity-like force. Any type of system could have been chosen and future versions will allow for the creation and simulation of arbitrary general systems. For more information on this program and modeling paradigm see: www.Anandavala.info/TASTMOTNOR/code/v3.2b/SMNPS3_1.html Please send any bug reports to john.ringland[AT]anandavala.info with the words "bug report v3.2b" somewhere in the subject. This would be much appreciated and will help me improve the program over time. Any other comments or suggestions are also welcomed. Changes since v3.1: ------------------- There are many small changes but the main difference is... There are two ways to represent a system matrix and two ways to process one. v3.1 only illustrated the simplest, most brute force approach whereas v3.2 illustrates both representation methods and both processing methods. See the sub heading "Changing Computational Method:" below, which is in the section on "Model Parameters:" --------- Contents: --------- The Program: The Simulated System: Interacting with the Simulation: Billiards Mode: Model Parameters: Exercises: Trouble Shooting: ------------ The Program: ------------ Unzip the folder then run "particle.bat". In Windows: If you wish to place an icon on your desktop right click and drag the file "particle.bat" onto your desktop and then from the menu choose to create a shortcut. In some windows environments you may need to execute the program from a full screen dos prompt in order for the dos graphics routines to work. This is only a very simple example of some of the core functionality of SMN, but SMN allows for many advanced features which are unique to SMN. These features are not implemented yet, but version 3.2 will be out soon with more features and fututre versions will become gradually more general, flexible and will exhibit advanced system analysis and simulation features. --------------------- The Simulated System: --------------------- The system consists a series of particles scattered in space. One can interact with these particles and thereby construct systems of particles. The force calculation has been modified (in a non-physical manner) to be repulsive at close range so the particles also exhibit solidity. The simulation is not meant to be physically realistic to the n'th degree, it is just a simple illustration of the core simulation capacities of the SMN modeling paradigm. The system model is defined in the file "smModels.ex" which is itself written in the programming language "Euphoria" (www.rapideuphoria.com). -------------------------------- Interacting with the Simulation: -------------------------------- When the simulation runs there is a system of particles displayed on the screen. One may interact with these by changing their empirical (observable) states. * 'p' = toggle pause on and off, whilst paused one can still edit the model * 'z' = Zoom in (>1) and out (<1) * 'b' = toggle billiards mode on and off * 'f' = toggle drawFilledParticles on and off * 'v' = view system state * 'r' = reload current model (restore model) * 's' = save current model * 'l' = load a new model * 'h' or '?' = quick help screen * any other key = show main menu * use the left mouse button to drag particles around * use the right mouse button to select particles and edit their properties * click the left or right mouse button in empty space to clean up the graphics Note: in billiards mode one can shoot particles around using the mouse as a billiard cue. In NON-biliards mode one can grab a particle and use it to push or pull other particles around. One can also vary the strength of the impulse force applied by the "billiard cue" via the main menu. If one left clicks on a particle one can drag it to a new position on the screen. Or in billiards mode one uses the left mouse button to apply an impulse force to particles. Press 'b' to toggle between these modes. If one right clicks on a particle its observable state is displayed (e.g. position, velocity, force) and one can edit the values to construct scenarios. If one presses any key that is not associated with an option above then the main menu is displayed. The rest of the interface should be self explanatory. --------------- Billiards Mode: --------------- One can toggle billiards mode by pressing 'b' and then shoot particles around using the mouse as a billiard cue. One can also vary the strength of the impulse force via the main menu. Click the left mouse button on a particle and drag it. This draws out a fine white line that represents a sort of billiards cue. The direction in which the line is pointing indicates the direction of the applied force. The length of the line represents the strength of the applied force. When the mouse is released an impulse force is applied to the particle and it responds appropriately, perhaps by flying off screen or bouncing into other particles. ----------------- Model Parameters: ----------------- The system model is either stored as a sequence of parameters in the file "Models.txt" where you can add your own model parameters, or it is stored as an actual model file (*.P32 as a suffix but that is not essential). You can also create a model by typing in a parameter sequence during runtime. Generally one creates a model using a set of parameters, this can then be adjusted into some configuration (perhaps adding particles and moving them around and changing their properties). This can then saved as a model file, ready to be loaded and further developed. example of a parameter sequence for two particles: ------- sequence of coords sequence time friction radius softness | of masses step | size | scale| | | | | | | | | {{{360,210},{320,260}}, {1,1000}, 0.08, 0.05, 61, 61, 4e2, 0} Note: mass, size, radius and softness can be either a sequence of values for each particle or a single value to be applied to all particles. time step: determines the temporal resolution of the simulation, the duration between computed moments. This is a single value that applies to the whole simulation. size: is the size of a particle as it is visually represented on the screen. This parameter has no effect on the simulated dynamics. radius: is the size of the particle within the computed dynamics. This parameter does effect the simulated dynamics. softness: determines the degree of solidity of the particles softness = 0 means particles repel each other at close range softness = 1 means particles may pass through each other Friction: relates to the viscosity of space. f=0 means no viscosity and f=1 means full friction or maximum viscosity. scale: is a scaling factor to tune the strength of the gravitational interaction scale = 0 turns gravity off. This is a single value that applies to the whole simulation. Changing the scaling factor is equivalent to uniformly adjusting all of the particle masses. By modifying these one can design different particle simulations. Note: In order to get a stable system of particles the parameters need to be tuned appropriately, otherwise they may just fly off and disperse or fall together into a clump. E.g. if one increases the simulation time-step, each simulated step becomes larger, thus paticles may jump very close together in a single leap, and with repulsive particles they are then exposed to a Huge force that propels them far apart. Thus if one increases the time-step one should also reduce the force scaling factor. Or if one decreases the time-step one may wish to turn up the force scaling factor. Or one could also adjust the masses. Changing Computational Method: ------------------------------ From the edit model menu one can change the underlying matrix type from full representation to sparse represntation. A full matrix represents all elements whereas a sparse matrix represents only the NON-ZERO elements. One can also switch from full processing to energy flow processing. With full processing every causal interaction pathway is computed in every moment whereas with energy flow processing only those pathways that are communicating new information are computed, so if nothing is happening (no energy flow) then nothing need be computed. These two options given no efficiency gains in this context since every system (particle) interacts with every other system so the matrix is not very sparse to begin with. Furthermore, every state variable changes in each moment so there is always energy flowing along all causal pathways. Due to these reasons these two options only result in extra computational overhead without any efficiency gain, but they have been included here simply to show that they do work and the resulting simulated dynamics is identical regardless of which representation or processing method is used. These methods are most effective in the case of sparsely interacting systems such as in most engineering applications. Note: as one adds more particles the simulation becomes more computationally intensive, hence the on-screen dynamics will slow down. However this effect is greatly accentuated by the very basic graphics routines used to display the particles, thus the more of the screen that is to be filled, the slower the program runs. One can see this by using "filled particles" and increasing the on-screen size of the particles, which doesn't effect the computational load of the simulation at all, but nevertheless the dynamics slow down considerably. To better gauge the efficiency of the algorithm itself simply press (f) to toggle from filled to hollow particle representations. But this still has a significant graphics overhead for large particles so one could set all on-screen sizes to 10 (from simulation -> any key -> model menu (3) -> change sreen size (6) -> then enter 10 and hit return. This doesn't effect the dynamics of the simulation, it just represents all particles as small dots regardless of the 'radius' within the simulated dynamics. -------- Exercises: -------- Ex1: Starting with the default model of three particles, get a feel for how they behave, i.e. their solidity due to close range repulsion (hard or fermionic like). Now change them all to soft (or bosonic like) particles that may pass straight through each other without repulsion. (from simulation: (any key) -> edit model (3) -> change softness values (8) -> then enter 1 to make them all maximally 'soft'. Now watch how they behave. Ex2: Reload the default model (r) or reset their softness values to zero. Then pause the simulation (p), then place one large particle almost directly on top of the other large particle (left mouse drag), then un-pause the simulation (p) and see what happens. You will then probably need to reload the current model (r) or load a new model; either (l) to load a model from file or create a model from a parameter set as described above. Ex3: Load up model parameters 14 (from simulation: (any key) -> edit model (3) -> create or load model (9) -> create model from parameters (4) -> select the 14'th parameter set (14) ) These are all hard particles. With the simulation running, grab the central particle (left mouse) and move it about. This is a strongly interacting particle (large relative mass) and one can use it to shephard other particles around. Ex4: Go into billiards mode (b) and apply a force to a particle (left mouse). Adjust the impulse force from the main menu if desired. Ex5: First pause then drag a particle away from the main group of particles, then edit it's velocity (right click -> change velocity) to send it into the main group as a projectile, or use the billiard method to propel the particle, then un-pause the simulation and see what happens. If they are soft particles the projectile will pass straight through but if they are hard there will be scattering. However if the impulse force is HUGE it will send the particle flying through the others so fast that they do not have time to interact and scatter. Ex5: Or try adding or deleting particles, or changing their radii, softness values, the simulation time-step, etc from the edit model menu. Ex6: Changing the computational method. From the edit model menu (15) will toggle between full and sparse matrice and (16) will toggle between full and energy flow processing. ----------------- Trouble Shooting: ----------------- If you have any problems, let me know and I will attempt to resolve it. Here I'll build a list of known problems and ways around them. ---------------- There are many enhancements in progress and these will be released as they are ready. The next major release will probably utilise the general principles illustrated in this example but develop them for arbitrary systems, not just systems of particles. Then I will construct a simple piece of software using SMN and people may explore it as a system model.