Commit 57bd7d76 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed issue with unavailable values showing up in funtional statistics.

parent f625de42
Pipeline #79028 skipped with stage
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -32,9 +32,6 @@
"use strict";
let DataStore = require('../material-mod/DataStore.js');
// global state vars
let materialId = null;
let searchResults = false;
......@@ -91,10 +88,12 @@ function getCalcMapByFunctional(summaryCalcSet) {
if (functCalcMap.has(calc.functional_type)) {
functCalcMap.get(calc.functional_type).add(calc.calc_id);
} else { // New functional
let newFunctionalArray = new Set();
newFunctionalArray.add(calc.calc_id);
functCalcMap.set(calc.functional_type, newFunctionalArray);
} else { // New functional, not build if value is unavailable
if (calc.functional_type !== "unavailable") {
let newFunctionalArray = new Set();
newFunctionalArray.add(calc.calc_id);
functCalcMap.set(calc.functional_type, newFunctionalArray);
}
}
});
return functCalcMap;
......@@ -345,85 +344,37 @@ function getAverage(array){
}
function getQuantityStatsMap(calcs) {
// Determine which statistics to build based on system type
let quantities;
let materialType = "";
let labelMap = {
volume: 'Volume (ų)',
atomic_density: 'Atomic density (Å⁻³)',
mass_density: 'Mass density (kg/m³)',
lattice_a: 'a (Å)',
lattice_b: 'b (Å)',
lattice_c: 'c (Å)'
};
if (materialType == "bulk") {
quantities = ['volume', 'atomic_density', 'mass_density', 'lattice_a', 'lattice_b', 'lattice_c'];
} else {
quantities = ['lattice_a', 'lattice_b', 'lattice_c'];
}
let quantitiesMap = new Map();
// Request quantity statistics from the server. The statistics are calculated
// on the server to keep the GUI responsive in case of large number of
// calculations.
let matId = DataStore.getMaterialData().material_id;
let query = JSON.stringify({calculations: calcs});
serverReqPOST(getMaterialStatsURL(matId), query, e3 => {
let results = JSON.parse(e3.target.response);
console.log(results);
console.log(e3);
});
//serverReqPOST(getMaterialStatsURL(matId), {calculations: calcs}, e3 => {
//let results = JSON.parse(e3.target.response).results;
//console.log(e3);
//console.log(results);
//});
return quantitiesMap;
//function getQuantityStatsMap(calcs) {
// OLD
//if (calcs.values().next().value.cell_volume === null){ // not bulk type volume of a calc null
//// Determine which statistics to build based on system type
//let quantities;
//let materialType = "";
//let labelMap = {
//volume: 'Volume (ų)',
//atomic_density: 'Atomic density (Å⁻³)',
//mass_density: 'Mass density (kg/m³)',
//lattice_a: 'a (Å)',
//lattice_b: 'b (Å)',
//lattice_c: 'c (Å)'
//};
//if (materialType == "bulk") {
//quantities = ['volume', 'atomic_density', 'mass_density', 'lattice_a', 'lattice_b', 'lattice_c'];
//} else {
//quantities = ['lattice_a', 'lattice_b', 'lattice_c'];
//labels = ['a (Å)', 'b (Å)', 'c (Å)'];
//}
//quantities.forEach( (quantity, index) => {
//let array= [];
//calcs.forEach( calc => {
//let value;
//if (quantity === 'volume') value = calc.cell_volume/1e-30;
//else if (quantity === 'atomic_density') value = calc.atomic_density*1e-30;
//else if (quantity === 'mass_density') value = calc.mass_density;
//else if (quantity.indexOf('lattice') >= 0){
//let tempLattParams= getNumberArray(calc.lattice_parameters);
//if (quantity === 'lattice_a') value = tempLattParams[0]/1e-10;
//else if (quantity === 'lattice_b') value = tempLattParams[1]/1e-10;
//else if (quantity === 'lattice_c') value = tempLattParams[2]/1e-10;
//}
//array.push(value);
//});
//let stats = {};
//stats.data = array;
//stats.min = Math.min.apply(null, array);
//stats.max = Math.max.apply(null, array);
//stats.equal = (stats.min === stats.max);
//let lls = labels[index].split(':');
//stats.label = lls[0];
//if (lls.length === 2) stats.units = lls[1];
//else stats.units = '';
//let decimals = 3;
//if (quantity === 'mass_density') decimals = 1;
//stats.html = getAverage(stats.data).toFixed(decimals)+
//' &nbsp; <span style="font-size: 0.9em">['+stats.min.toFixed(decimals)
//+' , '+stats.max.toFixed(decimals)+']</span>';
//quantitiesMap.set(quantity, stats);
//let quantitiesMap = new Map();
//// Request quantity statistics from the server. The statistics are calculated
//// on the server to keep the GUI responsive in case of large number of
//// calculations.
//let matId = DataStore.getMaterialData().material_id;
//let query = JSON.stringify({calculations: calcs});
//serverReqPOST(getMaterialStatsURL(matId), query, e3 => {
//let results = JSON.parse(e3.target.response);
//});
//return quantitiesMap;
}
//}
function toAngstromMinus3(density){
......@@ -487,15 +438,6 @@ function addBandGapData(calcJson, bsData){
}
}*/
/*
function is2DSystem_temporary_patch(){
//console.log('TEMPORARY PATCH is2DSystem:', DataStore.getMaterialData());
return DataStore.getMaterialData().system_type === '2D';
}
*/
module.exports = {
searchResults,
materialId,
......@@ -530,7 +472,6 @@ module.exports = {
getLatticeAnglesValues: getLatticeAnglesValues,
rad2degree: rad2degree,
m3ToAngstrom3: m3ToAngstrom3,
getQuantityStatsMap: getQuantityStatsMap,
toAngstromMinus3,
getMaterialTitle,
getMinMaxHTML: getMinMaxHTML,
......
......@@ -21,6 +21,7 @@
It stores the data loaded from the backend (immutable).
In addition it creates app life-time entities for convenience
*/
let util = require('../common/util.js');
let materialData;
let groups;
......@@ -49,7 +50,16 @@ function getIdealizedStructure(){
}
function setCalculations(calcsFromAPI){
// Clean up null values already here.
calcs = calcsFromAPI.results;
calcs.forEach(function(calc, index) {
let functional_type = util.getDefault(calc.functional_type);
let core_electron_treatment = util.getDefault(calc.core_electron_treatment);
this[index].functional_type = functional_type;
this[index].core_electron_treatment = core_electron_treatment;
}, calcs);
representatives = calcsFromAPI.representatives;
for (let i = 0; i < calcs.length; i++) {
calcMap.set(calcs[i].calc_id, calcs[i]);
......
......@@ -400,9 +400,9 @@ class MethodologyDetails extends DetailsViewBase {
this.sortedCalcs.push({
calc_id: c.calc_id,
type: calcType,
functional_type: util.getDefault(c.functional_type),
functional_type: c.functional_type,
code: c.code_name,
core_electron_treatment: util.getDefault(c.core_electron_treatment),
core_electron_treatment: c.core_electron_treatment,
basis_set_type: c.basis_set_type,
dataCalcProps: calcType+','+c.functional_type+','+c.code_name+
','+c.core_electron_treatment+','+c.basis_set_type,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment