Init speed.
Kinetic theory predicts that particles in thermal equilibrium have the same average kinetic energy. This holds true regardless of the size and mass of the particle. In this simulation, the red particle has 40x the mass of the smaller particles. The green test particle has the same mass as the blue particles but has been tagged as a data source in order to communicate with other applets. JavaScript is used to enable the inter-applet communication between the ensemble and the graph. The connection can show any analytic function of the position and velocity components including the particle speed or kinetic energy.
This page contains two Physlets that are able to share data using their common superclass, SApplet. The Molecular Physlet is able to tag a particle as a data source. In particular, any tagged particle can deliver x, y, vx, and vy values to a data listener. This script tags two particles and assigns these data sources to two different series in the DataGraph Physlet.
<script language="JavaScript">
function initApplet(){ document.Molecular.setAutoRefresh(false); document.Molecular.setDefault(); document.Molecular.setShowControls(false); document.Molecular.setPeriodicH(false); document.Molecular.setPeriodicV(false); document.Molecular.createParticles(20); for(i=0;i<20;i++){ document.Molecular.setParticlePos(i,-8+16*Math.random(),-8+16*Math.random()); document.Molecular.setParticleVel(i,-5+10*Math.random(),-5+10*Math.random()); } document.Molecular.setParticlePos(0,0,0); document.Molecular.setParticleVel(0,0,0); document.Molecular.setParticleMass(0,40); document.Molecular.setParticleRGB(0,255,0,0); document.Molecular.setParticleSize(0,3.0); document.Molecular.setParticlePos(1,5,5); document.Molecular.setParticleVel(1,2,2); document.Molecular.setParticleRGB(1,0,255,0); pid1=document.Molecular.addParticleDataSource(0); pid2=document.Molecular.addParticleDataSource(1) document.Molecular.setAutoRefresh(true); document.DataGraph.setAutoscaleX(true); document.DataGraph.setAutoscaleY(true); document.DataGraph.setMinMaxX(0,6.5); document.DataGraph.setMinMaxY(-6,6); document.DataGraph.clearSeries(1); document.DataGraph.setSeriesStyle(1,true,0); document.DataGraph.setSeriesRGB(1,255,0,0); document.DataGraph.clearSeries(2); document.DataGraph.setSeriesStyle(2,true,0); document.DataGraph.setSeriesRGB(2,0,255,0); document.DataGraph.setLabelY("Speed"); document.DataGraph.setLabelX("Time"); document.DataGraph.setTitle("Speed vs Time"); gid=document.DataGraph.getGraphID(); document.Molecular.deleteDataConnections(); document.Molecular.makeDataConnection(pid1,gid,1,"t","sqrt(vx*vx+vy*vy)"); document.Molecular.makeDataConnection(pid2,gid,2,"t","sqrt(vx*vx+vy*vy)"); document.Molecular.forward(); } </script>