From b6b937ab0c0efc692560f78041b0830eb2241308 Mon Sep 17 00:00:00 2001 From: ANDREA ALFONSI Date: Mon, 14 Jun 2021 13:16:17 -0600 Subject: [PATCH 1/3] fix --- tests/framework/user_guide/ravenTutorial/RomLoad.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/framework/user_guide/ravenTutorial/RomLoad.xml b/tests/framework/user_guide/ravenTutorial/RomLoad.xml index 9fa826620e..675963c665 100644 --- a/tests/framework/user_guide/ravenTutorial/RomLoad.xml +++ b/tests/framework/user_guide/ravenTutorial/RomLoad.xml @@ -23,11 +23,7 @@ - - sigma-A,decay-A - A, time -

3

-
+
From 6a2c1a5795fbbe10de0374e841cdfd8f2d70a6b5 Mon Sep 17 00:00:00 2001 From: aalfonsi Date: Wed, 22 Sep 2021 11:07:41 -0600 Subject: [PATCH 2/3] Closes #1665 --- framework/Samplers/Sampler.py | 86 +++++++++++++++++++++++++++-------- framework/utils/frontUtils.py | 2 +- 2 files changed, 67 insertions(+), 21 deletions(-) diff --git a/framework/Samplers/Sampler.py b/framework/Samplers/Sampler.py index 8d2fc435c7..b7a92d3070 100644 --- a/framework/Samplers/Sampler.py +++ b/framework/Samplers/Sampler.py @@ -798,6 +798,14 @@ def _constantVariables(self): pbKey = ['ProbabilityWeight-'+key for key in self.constants.keys()] self.addMetaKeys(pbKey) self.inputInfo.update(dict.fromkeys(['ProbabilityWeight-'+key for key in self.constants.keys()],1.0)) + # update in batch mode + if self.inputInfo.get('batchMode',False): + for b in range(self.inputInfo['batchInfo']['nRuns']): + self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVars'].update(self.constants) + self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVarsPb'].update(dict.fromkeys( + self.constants.keys(),1.0)) + self.inputInfo['batchInfo']['batchRealizations'][b].update( + dict.fromkeys(['ProbabilityWeight-'+key for key in self.constants.keys()],1.0)) def _expandVectorVariables(self): """ @@ -807,8 +815,13 @@ def _expandVectorVariables(self): """ # by default, just repeat this value into the desired shape. May be overloaded by other samplers. for var,shape in self.variableShapes.items(): - baseVal = self.inputInfo['SampledVars'][var] - self.inputInfo['SampledVars'][var] = np.ones(shape)*baseVal + if self.inputInfo.get('batchMode',False): + for b in range(self.inputInfo['batchInfo']['nRuns']): + baseVal = self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVars'][var] + self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVars'][var] = np.ones(shape)*baseVal + else: + baseVal = self.inputInfo['SampledVars'][var] + self.inputInfo['SampledVars'][var] = np.ones(shape)*baseVal def _functionalVariables(self): """ @@ -818,9 +831,16 @@ def _functionalVariables(self): """ # generate the function variable values for var in self.dependentSample.keys(): - test=self.funcDict[var].evaluate("evaluate",self.values) - for corrVar in var.split(","): - self.values[corrVar.strip()] = test + if self.inputInfo.get('batchMode',False): + for b in range(self.inputInfo['batchInfo']['nRuns']): + values = self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVars'] + test=self.funcDict[var].evaluate("evaluate",values) + for corrVar in var.split(","): + self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVars'][corrVar.strip()] = test + else: + test=self.funcDict[var].evaluate("evaluate",self.values) + for corrVar in var.split(","): + self.values[corrVar.strip()] = test def _incrementCounter(self): """ @@ -869,7 +889,11 @@ def _reassignSampledVarsPbToFullyCorrVars(self): # assign the SampledVarsPb to the fully correlated vars for key in fullyCorrVars: for kkey in key.split(","): - self.inputInfo['SampledVarsPb'][kkey] = fullyCorrVars[key] + if not self.inputInfo.get('batchMode',False): + self.inputInfo['SampledVarsPb'][kkey] = fullyCorrVars[key] + else: + for b in range(self.inputInfo['nRuns']): + self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVarsPb'][kkey] = fullyCorrVars[key] def _reassignPbWeightToCorrelatedVars(self): """ @@ -877,14 +901,21 @@ def _reassignPbWeightToCorrelatedVars(self): @ In, None @ Out, None """ + pbWeights = {} for varName, varInfo in self.variables2distributionsMapping.items(): # Handle ND Case if varInfo['totDim'] > 1: distName = self.variables2distributionsMapping[varName]['name'] - self.inputInfo['ProbabilityWeight-' + varName] = self.inputInfo['ProbabilityWeight-' + distName] + pbWeights['ProbabilityWeight-' + varName] = self.inputInfo['ProbabilityWeight-' + distName] if "," in varName: for subVarName in varName.split(","): - self.inputInfo['ProbabilityWeight-' + subVarName.strip()] = self.inputInfo['ProbabilityWeight-' + varName] + pbWeights['ProbabilityWeight-' + subVarName.strip()] = pbWeights['ProbabilityWeight-' + varName] + # update pbWeights + self.inputInfo.update(pbWeights) + # if batchmode, update batch + if self.inputInfo.get('batchMode',False): + for b in range(self.inputInfo['batchInfo']['nRuns']): + self.inputInfo['batchInfo']['batchRealizations'][b].update(pbWeights) def generateInput(self,model,oldInput): """ @@ -987,20 +1018,35 @@ def pcaTransform(self,varsDict,dist): @ In, dist, string, the distribution name associated with given variable set @ Out, None """ - latentVariablesValues = [] - listIndex = [] - manifestVariablesValues = [None] * len(varsDict['manifestVariables']) - for index,lvar in enumerate(varsDict['latentVariables']): - for var,value in self.values.items(): - if lvar == var: + def _applyTransformation(values): + """ + Wrapper to apply the pca transformation + @ In, values, dict, dictionary of sampled vars + @ Out, values, dict, the updated set of values + """ + latentVariablesValues = [] + listIndex = [] + manifestVariablesValues = [None] * len(varsDict['manifestVariables']) + for index,lvar in enumerate(varsDict['latentVariables']): + value = values.get(lvar) + if lvar is not None: latentVariablesValues.append(value) listIndex.append(varsDict['latentVariablesIndex'][index]) - varName = utils.first(utils.first(self.distributions2variablesMapping[dist]).keys()) - varsValues = self.distDict[varName].pcaInverseTransform(latentVariablesValues,listIndex) - for index1,index2 in enumerate(varsDict['manifestVariablesIndex']): - manifestVariablesValues[index2] = varsValues[index1] - manifestVariablesDict = dict(zip(varsDict['manifestVariables'],manifestVariablesValues)) - self.values.update(manifestVariablesDict) + + varName = utils.first(utils.first(self.distributions2variablesMapping[dist]).keys()) + varsValues = self.distDict[varName].pcaInverseTransform(latentVariablesValues,listIndex) + for index1,index2 in enumerate(varsDict['manifestVariablesIndex']): + manifestVariablesValues[index2] = varsValues[index1] + manifestVariablesDict = dict(zip(varsDict['manifestVariables'],manifestVariablesValues)) + values.update(manifestVariablesDict) + return values + + if self.inputInfo.get('batchMode',False): + for b in range(self.inputInfo['batchInfo']['nRuns']): + values = self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVars'] + self.inputInfo['batchInfo']['batchRealizations'][b]['SampledVars'] = _applyTransformation(values) + else: + self.values = _applyTransformation(self.values) def _checkSample(self): """ diff --git a/framework/utils/frontUtils.py b/framework/utils/frontUtils.py index 64377469e8..c63eca57fc 100644 --- a/framework/utils/frontUtils.py +++ b/framework/utils/frontUtils.py @@ -117,4 +117,4 @@ def crowdingDistance(rank, popSize, objectives): crowdDist[front[sortedRank[0]]] = crowdDist[front[sortedRank[-1]]] = np.inf for i in range(1, len(front)-1): crowdDist[front[sortedRank[i]]] = crowdDist[front[sortedRank[i]]] + (objectives[front[sortedRank[i+1]], obj] - objectives[front[sortedRank[i-1]], obj]) / (fMax[obj]-fMin[obj]) - return crowdDist \ No newline at end of file + return crowdDist From 38c8a7dcde2fdc25609d614e93dee3774c7c962e Mon Sep 17 00:00:00 2001 From: aalfonsi Date: Thu, 21 Oct 2021 09:01:51 -0600 Subject: [PATCH 3/3] removed clearRunDir --- framework/Steps/Step.py | 6 +++++- .../RELAP5/test_relap5_code_interface.xml | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/framework/Steps/Step.py b/framework/Steps/Step.py index 410bd32211..b069d81718 100644 --- a/framework/Steps/Step.py +++ b/framework/Steps/Step.py @@ -22,6 +22,7 @@ #External Modules------------------------------------------------------------------------------------ import abc +import os #External Modules End-------------------------------------------------------------------------------- #Internal Modules------------------------------------------------------------------------------------ @@ -164,7 +165,10 @@ def _handleInput(self, paramInput): self.raiseAnError(IOError,printString.format(self.type,self.name,self.initSeed,'re-seeding')) if 'sleepTime' in paramInput.parameterValues: self.sleepTime = paramInput.parameterValues['sleepTime'] - self._clearRunDir = paramInput.parameterValues.get('clearRunDir', True) + if os.environ['RAVENinterfaceCheck'] == 'True': + self._clearRunDir = False + else: + self._clearRunDir = paramInput.parameterValues.get('clearRunDir', True) for child in paramInput.subparts: classType = child.parameterValues['class'] classSubType = child.parameterValues['type'] diff --git a/tests/framework/CodeInterfaceTests/RELAP5/test_relap5_code_interface.xml b/tests/framework/CodeInterfaceTests/RELAP5/test_relap5_code_interface.xml index 232952eac7..0d1b06166b 100644 --- a/tests/framework/CodeInterfaceTests/RELAP5/test_relap5_code_interface.xml +++ b/tests/framework/CodeInterfaceTests/RELAP5/test_relap5_code_interface.xml @@ -19,6 +19,7 @@ This is a requirement test now. Req. R-SI-1 Modified to check we can handle multiple words in the same card. Added csv xml node in the Code block for showing how to use it. + Removed clearRunDir flag since in case of interfaceCheck this is set to False automatically (see issue #1688) R-SI-1 @@ -115,7 +116,7 @@ - + snc01.i tpfh2o MyRELAP