-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* impement, test, doc * models * comments addressed
- Loading branch information
1 parent
e56324c
commit 82ce63a
Showing
8 changed files
with
269 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2017 Battelle Energy Alliance, LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import numpy as np | ||
|
||
def run(self,Input): | ||
""" | ||
Runs the model. | ||
@ In, self, object, RAVEN's API storage object | ||
@ In, Input, dict, RAVEN's dictionary storage object | ||
@ Out, None | ||
""" | ||
self.z = self.x*self.C + self.D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2017 Battelle Energy Alliance, LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import numpy as np | ||
|
||
def run(self,Input): | ||
""" | ||
Runs the model. | ||
@ In, self, object, RAVEN's API storage object | ||
@ In, Input, dict, RAVEN's dictionary storage object | ||
@ Out, None | ||
""" | ||
self.A = self.a * 10 | ||
self.B = self.b * 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<Simulation verbosity="debug"> | ||
<TestInfo> | ||
<name>framework/Samplers.DataObjectConstants</name> | ||
<author>talbpaul</author> | ||
<created>2018-11-14</created> | ||
<classesTested>Sampler</classesTested> | ||
<description> | ||
Tests using a DataObject external to a Step as a source of constants for a Sampler. | ||
The models are very simple, so to regold, assure the correct values pass through for | ||
the constants and final result is obtained according to the models. | ||
</description> | ||
</TestInfo> | ||
|
||
<RunInfo> | ||
<WorkingDir>DataObjectConstants</WorkingDir> | ||
<Sequence>presample, sample, print</Sequence> | ||
</RunInfo> | ||
|
||
<Steps> | ||
<MultiRun name="presample"> | ||
<Input class="DataObjects" type="PointSet">pre_placeholder</Input> | ||
<Model class="Models" type="ExternalModel">premodel</Model> | ||
<Sampler class="Samplers" type="Grid">pregrid</Sampler> | ||
<Output class="DataObjects" type="PointSet">presamples</Output> | ||
</MultiRun> | ||
<MultiRun name="sample"> | ||
<Input class="DataObjects" type="PointSet">placeholder</Input> | ||
<Model class="Models" type="ExternalModel">model</Model> | ||
<Sampler class="Samplers" type="Grid">grid</Sampler> | ||
<Output class="DataObjects" type="PointSet">samples</Output> | ||
</MultiRun> | ||
<IOStep name="print"> | ||
<Input class="DataObjects" type="PointSet">presamples</Input> | ||
<Input class="DataObjects" type="PointSet">samples</Input> | ||
<Output class="OutStreams" type="Print">presamples</Output> | ||
<Output class="OutStreams" type="Print">samples</Output> | ||
</IOStep> | ||
</Steps> | ||
|
||
<DataObjects> | ||
<PointSet name="pre_placeholder"> | ||
<Input>a,b</Input> | ||
</PointSet> | ||
<PointSet name="presamples"> | ||
<Input>a,b</Input> | ||
<Output>A,B</Output> | ||
</PointSet> | ||
<PointSet name="placeholder"> | ||
<Input>x</Input> | ||
</PointSet> | ||
<PointSet name="samples"> | ||
<Input>x,C,D</Input> | ||
<Output>z</Output> | ||
</PointSet> | ||
</DataObjects> | ||
|
||
<Models> | ||
<ExternalModel name="premodel" subType="" ModuleToLoad="premodel.py"> | ||
<variables>a,b,A,B</variables> | ||
</ExternalModel> | ||
<ExternalModel name="model" subType="" ModuleToLoad="model.py"> | ||
<variables>x,z,C,D</variables> | ||
</ExternalModel> | ||
</Models> | ||
|
||
<Distributions> | ||
<Normal name="dist"> | ||
<mean>0</mean> | ||
<sigma>0.1</sigma> | ||
</Normal> | ||
</Distributions> | ||
|
||
<Samplers> | ||
<Grid name="pregrid"> | ||
<variable name="a"> | ||
<distribution>dist</distribution> | ||
<grid construction="equal" type="CDF" steps="1">0.1 0.9</grid> | ||
</variable> | ||
<variable name="b"> | ||
<distribution>dist</distribution> | ||
<grid construction="equal" type="CDF" steps="1">0.1 0.9</grid> | ||
</variable> | ||
</Grid> | ||
<Grid name="grid"> | ||
<ConstantSource class="DataObjects" type="PointSet">presamples</ConstantSource> | ||
<ConstantSource class="DataObjects" type="PointSet">presamples</ConstantSource> | ||
<variable name="x"> | ||
<distribution>dist</distribution> | ||
<grid construction="equal" type="CDF" steps="2">0.1 0.9</grid> | ||
</variable> | ||
<constant name="C" source="presamples" index="0">A</constant> | ||
<constant name="D" source="presamples" index="1">B</constant> | ||
</Grid> | ||
</Samplers> | ||
|
||
<OutStreams> | ||
<Print name="presamples"> | ||
<type>csv</type> | ||
<source>presamples</source> | ||
<what>input,output</what> | ||
</Print> | ||
<Print name="samples"> | ||
<type>csv</type> | ||
<source>samples</source> | ||
<what>input,output</what> | ||
</Print> | ||
</OutStreams> | ||
|
||
</Simulation> |
5 changes: 5 additions & 0 deletions
5
tests/framework/Samplers/gold/DataObjectConstants/presamples.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
a,b,A,B | ||
-0.128155156554,-0.128155156554,-1.28155156554,-1.28155156554 | ||
-0.128155156554,0.128155156554,-1.28155156554,1.28155156554 | ||
0.128155156554,-0.128155156554,1.28155156554,-1.28155156554 | ||
0.128155156554,0.128155156554,1.28155156554,1.28155156554 |
Oops, something went wrong.