Osmosis




Init

This simulation shows a mass-dependent transmission through a semi-permeable membrane.   The function is set in the embedding parameter to be:

<param name="Probability" value="0">

A  method call can then be used to set a mass dependent transmission probability.

document.Molecular.setProbabilityFunction("0.2-0.2*floor(0.5+m)");

Click on the enable diffusion button to invoke this method.   Since the red particles have a mass of 0.3 and the blue particles have a mass of 0.9, the red particles have a 20% transmission probability while the blue particles are not transmitted.

Script Example

<script language="JavaScript">

function initApplet(){
    document.Molecular.setAutoRefresh(false); 
    document.Molecular.setDefault();
    document.Molecular.setDefaultColor(255,0,0);
    document.Molecular.setDefaultMass(0.3);
    document.Molecular.setDefaultSize(0.3);
    document.Molecular.createParticlesL(20);

    document.Molecular.setDefaultColor(0,0,255);
    document.Molecular.setDefaultMass(0.9);
    document.Molecular.setDefaultSize(0.6);
    document.Molecular.createParticlesR(10);
    document.Molecular.setAutoRefresh(true); 

    document.DataTable.setAutoRefresh(false);   
    document.DataTable.setDefault();
    document.DataTable.setDataStride(1,2);
    document.DataTable.setDataStride(2,2);
    document.DataTable.setDataStride(3,2);
    document.DataTable.setSeriesLabel(1,"P Left");
    document.DataTable.setSeriesLabel(2,"V Left");  
    document.DataTable.setSeriesLabel(3,"T Left");
    document.DataTable.setSeriesLabel(4,"N Left");
    document.DataTable.sizeToFit(true);
    document.DataTable.setAutoRefresh(true);   
    tid=document.DataTable.getTableID();

    document.DataTable2.setAutoRefresh(false);   
    document.DataTable2.setDefault();
    document.DataTable2.setDataStride(1,2);
    document.DataTable2.setDataStride(2,2);
    document.DataTable2.setDataStride(3,2);
    document.DataTable2.setSeriesLabel(1,"P Right");
    document.DataTable2.setSeriesLabel(2,"V Right");  
    document.DataTable2.setSeriesLabel(3,"T Right");
    document.DataTable2.setSeriesLabel(4,"N Right");
    document.DataTable2.sizeToFit(true);
    document.DataTable2.setAutoRefresh(true);   
    tid2=document.DataTable2.getTableID();


    document.Molecular.deleteDataConnections(); 
    eid=document.Molecular.getEnsembleLeftID();
    cid=document.Molecular.makeDataConnection(eid,tid,1,"pt+pr+pb+pl","0"); 
    document.Molecular.setConnectionSmoothing(cid,100);
    document.Molecular.makeDataConnection(eid,tid,2,"v","0");  
    document.Molecular.makeDataConnection(eid,tid,3,"t","0"); 
    document.Molecular.makeDataConnection(eid,tid,4,"n","0"); 

    eid=document.Molecular.getEnsembleRightID();
    cid=document.Molecular.makeDataConnection(eid,tid2,1,"pt+pr+pb+pl","0"); 
    document.Molecular.setConnectionSmoothing(cid,100);
    document.Molecular.makeDataConnection(eid,tid2,2,"v","0");  
    document.Molecular.makeDataConnection(eid,tid2,3,"t","0"); 
    document.Molecular.makeDataConnection(eid,tid2,4,"n","0"); 
  
    document.Molecular.forward();
}
</script>