Difference between revisions of "MemEOL"
From Desal Wiki
Line 41: | Line 41: | ||
var CONST_CONV_TO_UF = 'conversion_to_uf'; | var CONST_CONV_TO_UF = 'conversion_to_uf'; | ||
var CONST_REUSE_RO = 'reuse_as_ro'; | var CONST_REUSE_RO = 'reuse_as_ro'; | ||
+ | |||
+ | var rangesRO = { | ||
+ | "Designation":["High quality SWRO","High quality BWRO","Medium quality BWRO","Low quality BWRO","Medium quality NF"], | ||
+ | "High NaCl rejection range (%)":[99.9,99.7,99.2,98,96], | ||
+ | "Low NaCl rejection range (%)":[99.60,99.20,98.00,96.00,80.00], | ||
+ | "Min permeability range (l.m-2.h-1.bar-1)":[0.45,1.60,1.60,1.00,5.00] | ||
+ | }; | ||
//create value from each iteration | //create value from each iteration | ||
Line 125: | Line 132: | ||
} | } | ||
− | function conversionToUFCalc( | + | function conversionToUFCalc(scoreUF, damage){ |
if(damage === 1){ | if(damage === 1){ | ||
− | + | scoreUF = 0; | |
} | } | ||
− | return | + | return scoreUF; |
+ | } | ||
+ | |||
+ | function calculateROReuseQuality(damage, minPermeability, saltRejection){ | ||
+ | var j=0; | ||
+ | var k=0; | ||
+ | //if the membrane is physically damaged it can not be reused for RO. | ||
+ | if(damage===1){ | ||
+ | return -1; | ||
+ | } | ||
+ | for (var item in rangesRO) { | ||
+ | if(j===0){ | ||
+ | k=rangesRO[item].length; | ||
+ | } else if (k!==rangesRO[item].length) { | ||
+ | console.log('k!==rangesRO[item].length'); | ||
+ | throw new Error('k!==rangesRO[item].length.'); //break the script | ||
+ | } else { | ||
+ | j++; | ||
+ | } | ||
+ | } | ||
+ | var x=1; | ||
+ | var y=0; | ||
+ | for(y=0; y<k; y++){ | ||
+ | if(rangesRO[x][y]>saltRejection && (rangesRO[x+1][y]<saltRejection && rangesRO[x+2][y]>minPermeability)){ //max < rejection < min. perm > minPerm | ||
+ | return y; | ||
+ | } | ||
+ | } | ||
+ | return -1; | ||
} | } | ||
Line 177: | Line 211: | ||
} | } | ||
} | } | ||
+ | //adjust UF score | ||
if(scoreObject.hasOwnProperty(CONST_CONV_TO_UF)){ | if(scoreObject.hasOwnProperty(CONST_CONV_TO_UF)){ | ||
scoreObject[CONST_CONV_TO_UF] = conversionToUFCalc(scoreObject[CONST_CONV_TO_UF], getPhysicalDamage()); | scoreObject[CONST_CONV_TO_UF] = conversionToUFCalc(scoreObject[CONST_CONV_TO_UF], getPhysicalDamage()); | ||
Line 184: | Line 219: | ||
console.log(scoreObject[property]); | console.log(scoreObject[property]); | ||
} | } | ||
− | } | + | } |
− | + | //adjust RO score & determine RO reuse quality | |
+ | var roReuseResult=0; | ||
+ | if(scoreObject.hasOwnProperty(CONST_REUSE_RO)){ | ||
+ | roReuseResult = calculateROReuseQuality(getPhysicalDamage(), getPermeability(), getNaClRejection()); | ||
+ | if(reReuseResult===-1){ | ||
+ | scoreObject[CONST_REUSE_RO]=0; | ||
+ | } | ||
+ | } | ||
+ | //determine highest score & second highest scores | ||
+ | var max=-1; | ||
+ | var maxName=""; | ||
+ | var second=-1; | ||
+ | var secondName=""; | ||
+ | for (var property in scoreObject) { | ||
+ | if (scoreObject.hasOwnProperty(property)) { | ||
+ | if(scoreObject[property]>max){ | ||
+ | max = scoreObject[property]; | ||
+ | maxName=property; | ||
+ | } else if (scoreObject[property]===max) { | ||
+ | second = scoreObject[property]; | ||
+ | secondName=property; | ||
+ | //ignore case that max===second===third | ||
+ | } else if (scoreObject[property]>=second) { | ||
+ | second = scoreObject[property]; | ||
+ | secondName=property; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | console.log(maxName + ': ' + String(max)); | ||
+ | console.log(secondName + ': ' + String(second)); | ||
}); | }); | ||
}); | }); |
Revision as of 07:20, 10 December 2014
Introduction text