############################################ #### SMN v5.0 ParticleDraw (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 -- modified 2006-02-09 transformed the Particle Simulator into ParticleDraw -- modified 2006-02-14 optimised the algorithm into an SCSPL approach -- plus Many other features ------------------------------------------------------------------ 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. These can then be formed into small systems of particles with interesting properties, which are then used as dynamical 'brushes' within a drawing program. For more information on this program and modeling paradigm see: www.Anandavala.info/TASTMOTNOR/code/v5.0/ParticleDraw/SMNPD5_0.html Please send any bug reports to john.ringland[AT]anandavala.info with the words "bug report v5.0 ParticleDraw" 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. --------- Contents: --------- The Program: The Simulated System: Interacting with the Simulation: Billiards Mode: Model Parameters: Exercises: Trouble Shooting: ------------ The Program: ------------ Unzip the folder then run "ParticleDraw.bat". In Windows: If you wish to place an icon on your desktop right click and drag the file "ParticleDraw.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. 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 can 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. These systems of particles have been augmented with an associative network. That is, particles can be 'associated' with other particles. This is part of a transitional phase whereby the Particle Simulator forms part of a new "topic map" program for the creation of topic maps (or concept maps or mind maps). When two particles are associated there is a line drawn between them. If these lines are not tidied up as they sweep through space then the result is a drawing brush with multiple colours and complex dynamical behaviours. One simply grasp one of the particles and drags the enitire assembly around the screen, or one can propell it using the billiards mode. The system model is defined in the file "smModels.ex" and the interface is defined in the file "interact.e". The other files are either common SMN code or Euphoria code. All files are written in the programming language "Euphoria" (www.rapideuphoria.com) and are executed using the Euphoria interpreter (ex.exe). -------------------------------- 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. During the simulation: ## 'q' = Quit to main menu * '?' or 'h' = Help screen * 'p' = Pause, you can still edit the model * 's' = Step the simulation one moment at a time * 'z' = Zoom - (change brush size) * 'e' = Erase everything ## 'c' = change Colours * 'g' = change Grip_width value (for grasping particles when the are small) * 'f' = change throw Factor (when releasing a particle with velocity) * 'F' = change association Force scaling Factor (make associated particles interact more strongly) * 'B' = change Billiards impulse force ## 'b' = toggle Billiards mode * 'D' = toggle Draw mode (switch all drawing functionality on and off, use as an eraser whilst drawing) * 'V' = toggle Visible particles (make the brush invisible so it can be moved without marking the image) * 'T' = toggle particle Traces (particles can leave coloured traces) * 'L' = toggle clear Line mode (particle associations can leave traces) * 'a' = toggle Associating mode (left mouse makes/breaks associations) * 'A' = toggle Association drawing mode (show associations or not) ## 'v' = View system state (view state of a particular particle) * 't' = Tweak model parameters (change all kinds of system parameters) * 'r' = Reload model (refresh the particle system or brush) * 'u' = Update model (make the current system reloadable with 'r') * 'i' = load or save Image * 'm' = load or save Model * use the left mouse button to drag particles around, * click once to grasp and click once more to release. * use the right mouse button to select particles and edit their properties 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 make or break associations in associating mode. If one left clicks on a particle one can drag it to a new position on the screen. 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. I will describe the new options in time, but most 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 clicked again an impulse force is applied to the particle and it responds appropriately, perhaps by flying accross the 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 (*.P50 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, these are then automatically formed into a ring of assciated particles. This can then be adjusted into some configuration (perhaps adding particles and moving them around, changing their properties and making and breaking associations). 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 or friction. Changing Computational Method: ------------------------------ From the edit model menu one can change 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. This option gives no efficiency gains in this context since every system (particle) interacts with every other system and every state variable changes in each moment so there is always energy flowing along all causal pathways. Due to these reasons this option only results in extra computational overhead without any efficiency gain, but it is included here simply to show that it works and the resulting simulated dynamics is identical regardless of which processing method is used. Energy flow 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 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. In such cases either reduce the onscreen size of the particles or change the zoom factor. These don't effect the dynamics of the simulation, it just changes the visual representation of the underlying system. -------- Exercises: -------- Ex1: Starting with the default three particle brush, grasp one particle (left click) then try moving it around, then try getting it swinging and then click once more to release the brush and then watch it swing about chaotically of its own accord (the associations induce an unbalanced force that causes the particles to swing about chaotically). Then press 'c' to choose a new colour scheme. Then press 'z' to change the zoom factor and notice that by zooming one effectively changes the size of the brush. Ex2: Increase the force field strength to make the brush go a bit wild ('t' then '14'), then when some of its particles fly way off-screen one may need to retreive them. Press 'z' to zoom out (small zoom factor, perhaps 0.01) and then press 'g' to change the grasp size, when the particles are very small on screen they can be hard to grasp with the mouse but a large grasp size makes it much easier. Then drag the particles back toward the center of the screen, release them, then zoom back in to an approriate level and readjust the grasp size, (when one zooms back in the grasp size must be changed back to a smaller value otherwise one cannot select particular systems at close range). Ex3: Starting with the default model of three particles, get a feel for how they behave, i.e. their tendency to pass right through each other (their soft or bosonic behaviour). Now change them all to hard (or fermionic) particles that experience close range repulsion, thus they now have solidity and they bounce off of each other ('t' -> change softness values (8) -> then enter 0 to make them all minimally 'soft'. Now watch how they behave. Note, you may need to adjust the force strength or time-step to make the new configuration stable. Ex4: Now press 'u' to update the model (brush type). Now whenever one presses 'r' to reload the model the current brush is brought back onto the screen in its current location. Try making some changes to the model, such as the masses, radii, on screen size, softness values, add or remove particles, time-step, friction, force strength or computational method. Then press 'r' to bring back the previously updated brush. Or one can also experiment with loading and saving different brushes, just press 'm' to load or save a Model. Also try loading or saving images by pressing 'i'. Note that the new image is super-imposed over the current image so if you want just the new image only, then press 'e' to erase the current image prior to loading the new image. Ex5: Given any brush system, change the associations between them and observe the changes in behaviour due to the different arrangement. Note, all particles interact via the force field but associated particles interact much more intensely. Thus one can create one way associations which induce unbalanced forces that give rise to chaotic dynamical brushes (create only two way associations if you wish to keep the forces balanced). To alter the associations press 'a' to toggle the Associating mode on or off. In this mode one clicks on one particle then drags a line accross to another particle and then clicks on it to release the line. If the particles are already associated this removes the association, but if they are not already associated this creates an association. Ex6: Using a brush with 'hard' particles pause the simulation 'p', then place one particle almost directly on top of another particle (left click, drag, left click), 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 or go out and retrieve the particles as described in ex2. Ex7: Load a new model from the list of model parameters kept in the text file "Models.txt". From the simulation: press 't' -> create or load model (9) -> create model from parameters (4) -> select the 14'th parameter set (14) ). This system consists of nine hard particles originally placed into a lattice. However the network of associations creates unbalanced forces and you may need adjust the time-step and force strength to stop this from going too wild. This model was modified to create the model "BRUSH03.P50" by removing one particle to break the ring into a line and then adjusting some model parameters to make its behaviour stable and useful. Ex8: Go into billiards mode (b) and apply a force to a particle (left click, drag, left click). Adjust the impulse force from the main menu if desired to tune the effect that this has on the particles. Ex9: First pause then drag a particle away from the main group of particles, then edit it's velocity (right click -> change velocity '3') 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 velocity or 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. Ex10: Changing the computational method. From the edit model menu (15) will toggle between full and energy flow processing. There is no overt difference to the functioning of the simulation however it is more efficient in some circumstances. ----------------- 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. Following this is the development of a "transcendent interface". All of the current programs provide an "empirical interface" that is a window into the "simulation space" or virtual universe. The transcendent interface is a window into the "design space" and it would allow one to graphically design and construct system models, whereas at present one must delve into the code of "smModels.ex" to do this.