### Starting the Layout Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Starts the force-directed layout simulation. This should be called after setting nodes and links. ```javascript force.start(); ``` -------------------------------- ### Symbol Polyfill and Setup Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html This section details the polyfill for the native Symbol object, including its implementation when native Symbols are not available and the setup for standard symbols and symbol registry. ```javascript var n,a,i,o=t("d"),s=t("./validate-symbol"),l=t("ext/global-this").Symbol,c=t("./lib/private/generate-name"),u=t("./lib/private/setup/standard-symbols"),h=t("./lib/private/setup/symbol-registry"),f=Object.create,p=Object.defineProperties,d=Object.defineProperty;if("function"==typeof l)try{String(l()),i=!0}catch(t){}else l=null;a=function(t){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return n(t)},e.exports=n=function t(e){var r;if(this instanceof t)throw new TypeError("Symbol is not a constructor");return i?l(e):(r=f(a.prototype),e=void 0===e?"":String(e),p(r,{" __description__":o("",e), "__name__":o("",c(e))}))},u(n),h(n),p(a.prototype,{constructor:o(n),toString:o("",(function(){return this.__name__}))}),p(n.prototype,{toString:o((function(){return"Symbol ("+s(this).__descrip ``` -------------------------------- ### Run Getting Started Example Source: https://github.com/usepa/wntr/blob/main/documentation/examples.md Execute the 'getting_started.py' example using Python in interactive mode to view simulation results and plots. Use 'exit()' to close Python. ```bash python -i getting_started.py ``` -------------------------------- ### Montgomery Reduction Setup Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Initializes parameters for Montgomery reduction, including shift, R, R^2, R inverse, and modulus inverse. This is crucial for efficient modular arithmetic. ```javascript function w(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function T(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)} ``` -------------------------------- ### Full Getting Started Example Source: https://github.com/usepa/wntr/blob/main/documentation/getting_started.md This example demonstrates importing WNTR, creating a water network model from an EPANET INP file, simulating hydraulics, and plotting simulation results on the network. It requires the Net3.inp file. ```python """ The following example demonstrates how to import WNTR, create a water network model from an EPANET INP file, simulate hydraulics, and plot simulation results on the network. """ # Import WNTR import wntr # Create a water network model wn = wntr.network.WaterNetworkModel('Net3') # Simulate hydraulics sim = wntr.sim.EpanetSimulator(wn) results = sim.run_sim() # Plot results on the network pressure_at_5hr = results.node['pressure'].loc[5*3600, :] wntr.graphics.plot_network(wn, node_attribute=pressure_at_5hr, node_size=30, title='Pressure at 5 hours') ``` -------------------------------- ### Framework Initialization Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Sets up the SVG framework, including clipping paths, groups for geo layers, and mock axes for projection calculations. ```javascript w.makeFramework=function(){var t=this,e=t.graphDiv,r=e._fullLayout,a="clip"+r._uid+t.id;t.clipDef=r._clips.append("clipPath").attr("id",a),t.clipRect=t.clipDef.append("rect"),t.framework=n.select(t.container).append("g").attr("class","geo "+t.id).call(s.setClipUrl,a,e),t.project=function(e){var r=t.projection(e);return r?[r[0]-t.xaxis._offset,r[1]-t.yaxis._offset]:[null,null]},t.xaxis={"_id":"x",c2p:function(e){return t.project(e)[0]}},t.yaxis={"_id":"y",c2p:function(e){return t.project(e)[1]}},t.mockAxis={type:"linear",showexponent:"all",exponentformat:"B"},u.setConvert(t.mockAxis,r)} ``` -------------------------------- ### Install WNTR Dependencies Source: https://github.com/usepa/wntr/blob/main/documentation/installation.md Installs all required and optional packages for WNTR from the requirements.txt file. Ensure you have pip installed. ```bash pip install -r requirements.txt ``` -------------------------------- ### Initialize Raster Source Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Sets up a raster tile source, including its URL, scheme, and tile size. ```javascript function r(r,n,a,i){e.call(this),this.id=r,this.dispatcher=a,this.setEventedParent(i),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.extend({type:"raster"},n),t.extend(this,t.pick(n,["url","scheme","tileSize"]))} ``` -------------------------------- ### Test Conda-Forge Installation of WNTR Source: https://github.com/usepa/wntr/blob/main/documentation/developers.md Steps to create a new conda environment, activate it, install WNTR from conda-forge, and verify the installation by printing the version. ```bash conda create --name test2 python=3.12 --no-default-packages conda activate test2 conda install -c conda-forge wntr python -c "import wntr; print(wntr.__version__)" ``` -------------------------------- ### Cube Rendering Setup Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Sets up the vertex and index buffers for rendering the cube. It also calculates and normalizes cube edge properties. ```javascript e.exports=function(t,e,r,i,p){a(s,e,t),a(s,r,s);for(var y=0,x=0;x<2;++x){u[2]=i[x][2];for(var b=0;b<2;++b){u[1]=i[b][1];for(var _=0;_<2;++)u[0]=i[_][0],f(l[y],u,s),y+=1}}var w=-1;for(x=0;x<8;++x){for(var T=l[x][3],k=0;k<3;++k)c[x][k]=l[x][k]/T;p&&(c[x][2]*=-1),T<0&&(w<0||c[x][2]*:not(.chart-root)").remove(), e = e ? l(e, r) : r, a || (a = o.Axis()), i = o.adapter.plotly().convert(e), a.config(i).render(u), t.data = e.data, t.layout = e.layout, c.fillLayout(t), e } return f.isPolar = !0, f.svg = function() { return a.svg() }, f.getConfig = function() { return e }, f.getLiveConfig = function() { return o.adapter.plotly().convert(a.getLiveConfig(), !0) }, f.getLiveScales = function() { return { t: a.angularScale(), r: a.radialScale() } }, f.setUndoPoint = function() { var t, n, a = this, i = o.util.cloneJson(e); t = i, n = r, h.add({ undo: function() { n && a(n) }, redo: function() { a(t) } }), r = o.util.cloneJson(i) }, f.undo = function() { h.undo() }, f.redo = function() { h.redo() } }, c.fillLayout = function(t) { var e = n.select(t).selectAll(".plot-container"), r = e.selectAll(".svg-container"), a = t.framework && t.framework.svg && t.framework.svg(), o = { width: 800, height: 600, paper_bgcolor: i.background, _container: e, _paperdiv: r, _paper: a }; t._fullLayout = l(o, t.layout) } ``` -------------------------------- ### Install WNTR using conda Source: https://github.com/usepa/wntr/blob/main/README.md Install the latest release of WNTR from Anaconda using conda. ```bash conda install -c conda-forge wntr ``` -------------------------------- ### Install WNTR using pip Source: https://github.com/usepa/wntr/blob/main/README.md Install the latest release of WNTR from PyPI using pip. ```bash pip install wntr ``` -------------------------------- ### Background Rendering Setup Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Initializes the WebGL buffer, VAO, and shader for drawing the background. This is used to set up the visual background plane. ```javascript e.exports=function(t){for(var e=[],r=[],s=0,l=0;l<3;++l)for(var c=(l+1)%3,u=(l+2)%3,h=[0,0,0],f=[0,0,0],p=-1;p<=1;p+=2){r.push(s,s+2,s+1,s+1,s+2,s+3),h[l]=p,f[l]=p;for(var d=-1;d<=1;d+=2){h[c]=d;for(var g=-1;g<=1;g+=2)h[u]=g,e.push(h[0],h[1],h[2],f[0],f[1],f[2]),s+=1}var m=c;c=u,u=m}var v=n(t,new Float32Array(e)),y=n(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),x=a(t,[{buffer:v,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:v,type:t.FLOAT,size:3,offset:12,stride:24}],y),b=i(t);return b.attributes.position.location=0,b.attributes.normal.location=1,new o(t,v,x,b)};var n=t("gl-buffer"),a=t("gl-vao"),i=t("./shaders").bg;function o(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n} ``` -------------------------------- ### Getting Binding for Paint Property Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Gets a binding object for a paint property. This is used to link shader uniforms to property values. ```javascript Ei.prototype.getBinding = function(t, e, r) { return new vi(t, e) } ``` -------------------------------- ### Initialize Rendering Context and Camera Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Sets up the WebGL rendering context, defines camera parameters, and initializes axes and spikes. This is typically the first step in setting up a 3D scene. ```javascript var T={eye:t.camera.eye||[2,0,0],center:t.camera.center||[0,0,0],up:t.camera.up||[0,1,0],zoomMin:t.camera.zoomMax||.1,zoomMax:t.camera.zoomMin||100,mode:t.camera.mode||"turntable",_ortho:w},k=t.axes||{},A=a(r,k);A.enable=!k.disable;var M=t.spikes||{},S=o(r,M),E=[],C=[],L=[],P=[],I=!0,z=!0,O=new Array(16),D=new Array(16),R={view:null,projection:O,model:D,_ortho:!1},F=(z=!0,[r.drawingBufferWidth,r.drawingBufferHeight]),B=t.cameraObject||n(e,T),N={gl:r,contextLost:!1,pixelRatio:t.pixelRatio||1,canvas:e,selection:x,camera:B,axes:A,axesPixels:null,spikes:S,bounds:y,objects:E,shape:F,aspect:t.aspectRatio||[1,1,1],pickRadius:t.pickRadius||10,zNear:t.zNear||.01,zFar:t.zFar||1e3,fovy:t.fovy||Math.PI/4,clearColor:t.clearColor||[0,0,0,0],autoResize:v(t.autoResize),autoBounds:v(t.autoBounds),autoScale:!!t.autoScale,autoCenter:v(t.autoCenter),clipToBounds:v(t.clipToBounds),snapToData:!!t.snapToData,onselect:t.onselect||null,onrender:t.onrender||null,onclick:t.onclick||null,cameraParams:R,oncontextloss:null,mouseListener:null,_stopped:!1,getAspectratio:function(){return{x:this.aspect[0],y:this.aspect[1],z:this.aspect[2]}},setAspectratio:function(t){this.aspect[0]=t.x,this.aspect[1]=t.y,this.aspect[2]=t.z,z=!0},setBounds:function(t,e){this.bounds[0][t]=e.min,this.bounds[1][t]=e.max},setClearColor:function(t){this.clearColor=t},clearRGBA:function(){this.gl.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}}; ``` -------------------------------- ### WTNR Tank Head Initialization and Rendering Setup Source: https://github.com/usepa/wntr/blob/main/documentation/_static/tank_head.html Initializes the WebGL context and sets up the rendering pipeline for lines. This includes defining buffers, textures, and shader programs. Use this for setting up the core rendering capabilities. ```javascript e.exports=function(t,e){var r,n,l,m,b,"=e.context,w=e.pick,T=e.regl,k={currentRafs:{},drawCompleted:!0,clearOnly:!1},A=function(t){for(var e={},r=0;r<=o;r+=4)e[v(r)]=t.buffer({usage:"dynamic",type:"float",data:new Uint8Array(0)});return e}(T),M=T.texture(u),S=[];C(e);var E=T({ profile:!1, blend:{enable:_,func:{srcRGB:"src alpha",dstRGB:"one minus src alpha",srcAlpha:1,dstAlpha:1},equation:{rgb:"add",alpha:"add"},color:[0,0,0,0]}, depth:{enable:!_,mask:!0,func:"less",range:[0,1]}, cull:{enable:!0,face:"back"}, scissor:{enable:!0,box:{x:T.prop("scissorX"),y:T.prop("scissorY"),width:T.prop("scissorWidth"),height:T.prop("scissorHeight")}}, viewport:{x:T.prop("viewportX"),y:T.prop("viewportY"),width:T.prop("viewportWidth"),height:T.prop("viewportHeight")}, dither:!1, vert:a, frag:i, primitive:"lines", lineWidth:1, attributes:A, uniforms:{ resolution:T.prop("resolution"), viewBoxPos:T.prop("viewBoxPos"), viewBoxSize:T.prop("viewBoxSize"), dim0A:T.prop("dim0A"), dim1A:T.prop("dim1A"), dim0B:T.prop("dim0B"), dim1B:T.prop("dim1B"), dim0C:T.prop("dim0C"), dim1C:T.prop("dim1C"), dim0D:T.prop("dim0D"), dim1D:T.prop("dim1D"), loA:T.prop("loA"), hiA:T.prop("hiA"), loB:T.prop("loB"), hiB:T.prop("hiB"), loC:T.prop("loC"), hiC:T.prop("hiC"), loD:T.prop("loD"), hiD:T.prop("hiD"), palette:M, contextColor:T.prop("contextColor"), mask:T.prop("maskTexture"), drwLayer:T.prop("drwLayer"), maskHeight:T.prop("maskHeight") }, offset:T.prop("offset"), count:T.prop("count") });function C(t){r=t.model,n=t.viewModel,l=n.dimensions.slice(),m=l[0]?l[0].values.length:0;var e=r.lines,a=w?e.color.map((function(t,r){return r/e.color.length})):e.color,i=function(t,e,r){for(var n,a=new Array(t*(o+4)),i=0,s=0;su&&(u=t[a].dim1.canvasX,o=a);0===s&&h(T,0,0,r.canvasWidth,r.canvasHeight);var p=function(t){var e,r,n,a=[[ ],[ ]];for(n=0;n<64;n++){var i=!t&&nMath.abs(s)?(c.boxEnd[1]=c.boxStart[1]+Math.abs(i)*(_*(s>=0?1:-1)),c.boxEnd[1]0){if(i<=0)return o;n=a+i}else{if(!(a<0))return o;if(i>=0)return o;n=-(a+i)}var s=33306690738754716e-32*n;return o>=s||o<=-s?o:h(t,e,r)},function(t,e,r,n){var a=t[0]-n[0],i=e[0]-n[0],o=r[0]-n[0],s=t[1]-n[1],l=e[1]-n[1],c=r[1]-n[1],u=t[2]-n[2],h=e[2]-n[2],p=r[2]-n[2],d=i*c,g=o*l,m=o*s,v=a*c,y=a*l,x=i*s,b=u*(d-g)+h*(m-v)+p*(y-x),_=7771561172376103e-31*((Math.abs(d)+Math.abs(g))*Math.abs(u)+(Math.abs(m)+Math.abs(v))*Math.abs(h)+(Math.abs(y)+Math.abs(x))*Math.abs(p));return b>_||-b>_?b:f(t,e,r,n)}];function u(t){if(2===t.length)return["sum(prod(",t[0][0],"),",t[1][1],"),prod(-",t[0][1],"),",t[1][0],"))"].join("")];for(var e=[],r=0;r