Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Development' into feature/v4/KLE_2D
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/source/bibliography.bib
#	docs/source/conf.py
  • Loading branch information
dimtsap committed Feb 1, 2023
2 parents 8bd92a8 + 55fed0b commit 8ea79d1
Show file tree
Hide file tree
Showing 112 changed files with 7,497 additions and 1,514 deletions.
8 changes: 3 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
|AzureDevops| |PyPIdownloads| |PyPI| |CondaSURG| |CondaPlatforms| |GithubRelease| |Binder| |Docs| |bear-ified|
|AzureDevops| |PyPIdownloads| |PyPI| |CondaPlatforms| |GithubRelease| |Binder| |Docs| |bear-ified|

.. |Docs| image:: https://img.shields.io/readthedocs/uqpy?style=plastic :alt: Read the Docs
.. |CondaSURG| image:: https://img.shields.io/conda/vn/SURG_JHU/uqpy?style=plastic :alt: Conda (channel only)
.. |CondaPlatforms| image:: https://img.shields.io/conda/pn/SURG_JHU/uqpy?style=plastic :alt: Conda
.. |GithubRelease| image:: https://img.shields.io/github/v/release/SURGroup/UQpy?style=plastic :alt: GitHub release (latest by date)
.. |AzureDevops| image:: https://img.shields.io/azure-devops/build/UQpy/5ce1851f-e51f-4e18-9eca-91c3ad9f9900/1?style=plastic :alt: Azure DevOps builds
Expand Down Expand Up @@ -35,7 +34,7 @@ Uncertainty Quantification with python (UQpy)
+ + +
| | Promit Chakroborty, Lukáš Novák, Andrew Solanto |
+-----------------------+------------------------------------------------------------------+
| **Contributors:** | Michael Gardner |
| **Contributors:** | Michael Gardner, Prateek Bhustali, Julius Schultz, Ulrich Römer |
+-----------------------+------------------------------------------------------------------+

Contact
Expand All @@ -61,7 +60,7 @@ Dependencies

* ::
Python >= 3.6
Python >= 3.9
Git >= 2.13.1

License
Expand Down Expand Up @@ -91,7 +90,6 @@ Using Conda
* ::

conda install -c conda-forge uqpy
conda install -c surg_jhu uqpy (latest version)

Clone your fork of the UQpy repo from your GitHub account to your local disk (to get the latest version):

Expand Down
24 changes: 12 additions & 12 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ jobs:
displayName: Install Anaconda packages
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
- bash: |
source activate myEnvironment
conda build . recipe --variants "{'version': ['$(GitVersion.SemVer)']}"
displayName: Build Noarch conda packages
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
- bash: |
source activate myEnvironment
anaconda login --username $(ANACONDAUSER) --password $(ANACONDAPW)
anaconda upload /usr/local/miniconda/envs/myEnvironment/conda-bld/noarch/*.tar.bz2
displayName: Upload conda packages
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
# - bash: |
# source activate myEnvironment
# conda build . recipe --variants "{'version': ['$(GitVersion.SemVer)']}"
# displayName: Build Noarch conda packages
# condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
#
# - bash: |
# source activate myEnvironment
# anaconda login --username $(ANACONDAUSER) --password $(ANACONDAPW)
# anaconda upload /usr/local/miniconda/envs/myEnvironment/conda-bld/noarch/*.tar.bz2
# displayName: Upload conda packages
# condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')

- job: "Create_Docker_images"
dependsOn: Build_UQpy_and_run_tests
Expand Down
16 changes: 8 additions & 8 deletions docs/code/RunModel/abaqus_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
==================================
"""


# %% md
#
# Import the necessary libraries.

# %%

import glob
import pickle
import time

import os
from UQpy.distributions import Normal, Uniform
from UQpy.run_model.RunModel import *
from UQpy.run_model.RunModel import RunModel
from UQpy.run_model.model_execution.ThirdPartyModel import ThirdPartyModel
from UQpy.sampling import MonteCarloSampling

calling_directory = os.getcwd()
Expand All @@ -36,12 +36,12 @@

# %%

abaqus_sfe_model = RunModel(model_script='abaqus_fire_analysis.py', input_template='abaqus_input.py',
output_script='extract_abaqus_output.py', var_names=var_names, ntasks=24,
model_dir='SFE_MCS', verbose=True, cores_per_task=1)
m = ThirdPartyModel(model_script='abaqus_fire_analysis.py', input_template='abaqus_input.py',
output_script='extract_abaqus_output.py', var_names=var_names,
model_dir='SFE_MCS', )
abaqus_sfe_model = RunModel(cores_per_task=1, ntasks=24, model=m)
print('Example: Created the model object.')


# %% md
#
# Towards defining the sampling scheme
Expand Down
16 changes: 5 additions & 11 deletions docs/code/RunModel/ls_dyna_example_multijob.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
==================================
"""


# %% md
#
# Import the necessary libraries.

# %%
from UQpy.distributions import Uniform
from UQpy.run_model.RunModel import RunModel
from UQpy.run_model.model_execution.ThirdPartyModel import ThirdPartyModel
from UQpy.sampling import MonteCarloSampling

# %% md
Expand Down Expand Up @@ -42,13 +42,7 @@
# Run the model.

# %%

run_ = RunModel(samples=x.samples, ntasks=6, model_script='dyna_script.py', input_template='dyna_input.k',
var_names=['x0', 'y0', 'z0', 'R0', 'x1', 'y1', 'z1', 'R1'], model_dir='dyna_test', cluster=True,
verbose=False, fmt='{:>10.4f}', cores_per_task=12)






m = ThirdPartyModel(model_script='dyna_script.py', input_template='dyna_input.k',
var_names=['x0', 'y0', 'z0', 'R0', 'x1', 'y1', 'z1', 'R1'], model_dir='dyna_test',
fmt='{:>10.4f}')
run_ = RunModel(samples=x.samples, ntasks=6, cores_per_task=12, model=m)
14 changes: 4 additions & 10 deletions docs/code/RunModel/ls_dyna_example_singlejob.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
==================================
"""


# %% md
#
# Import the necessary libraries.

# %%
from UQpy.distributions import Uniform
from UQpy.run_model.RunModel import RunModel
from UQpy.run_model.model_execution.ThirdPartyModel import ThirdPartyModel
from UQpy.sampling import MonteCarloSampling

# %% md
Expand Down Expand Up @@ -40,12 +40,6 @@
# Run the model.

# %%
run_ = RunModel(samples=x.samples, ntasks=1, model_script='dyna_script.py', input_template='dyna_input.k',
var_names=['x0', 'y0', 'z0', 'R0', 'x1', 'y1', 'z1', 'R1'], model_dir='dyna_test', cluster=True,
verbose=False, fmt='{:>10.4f}', cores_per_task=48)






m = ThirdPartyModel(model_script='dyna_script.py', input_template='dyna_input.k',
var_names=['x0', 'y0', 'z0', 'R0', 'x1', 'y1', 'z1', 'R1'], model_dir='dyna_test', fmt='{:>10.4f}')
run_ = RunModel(samples=x.samples, ntasks=1, cores_per_task=48, model=m)
92 changes: 45 additions & 47 deletions docs/code/RunModel/matlab_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
==================================
"""


# %% md
#
# The RunModel class is capable of passing input in different formats into a single computational model. This means that
Expand Down Expand Up @@ -64,6 +63,7 @@

from UQpy.sampling import MonteCarloSampling
from UQpy.run_model.RunModel import RunModel
from UQpy.run_model.model_execution.ThirdPartyModel import ThirdPartyModel
from UQpy.distributions import Normal
import time
import numpy as np
Expand Down Expand Up @@ -133,10 +133,11 @@
if pick_model == 'scalar' or pick_model == 'all':
# Call to RunModel - Here we run the model while instantiating the RunModel object.
t = time.time()
m = RunModel(ntasks=1, model_script='matlab_model_sum_scalar.py',
input_template='sum_scalar.m', var_names=names, model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model', fmt="{:>10.4f}", verbose=True)
model = ThirdPartyModel(model_script='matlab_model_sum_scalar.py',
input_template='sum_scalar.m', var_names=names, model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
model_dir='Matlab_Model', fmt="{:>10.4f}")
m = RunModel(ntasks=1, model=model)
m.run(x_mcs.samples)
t_ser_matlab = time.time() - t
print("\nTime for serial execution:")
Expand All @@ -145,7 +146,6 @@
print("The values returned from the Matlab simulation:")
print(m.qoi_list)


# %% md
#
# 1.2 Samples passed as list, no format specification, parallel execution
Expand All @@ -161,18 +161,18 @@
if pick_model == 'scalar' or pick_model == 'all':
# Call to RunModel with samples as a list - Again we run the model while instantiating the RunModel object.
t = time.time()
m = RunModel(samples=x_mcs_list, ntasks=2, model_script='matlab_model_sum_scalar.py',
input_template='sum_scalar.m', var_names=names, model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output', resume=False,
model_dir='Matlab_Model', verbose=True)
model = ThirdPartyModel(model_script='matlab_model_sum_scalar.py',
input_template='sum_scalar.m', var_names=names, model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
model_dir='Matlab_Model')
m = RunModel(samples=x_mcs_list, ntasks=2, model=model)
t_par_matlab = time.time() - t
print("\nTime for parallel execution:")
print(t_par_matlab)
print()
print("The values retured from the Matlab simulation:")
print(m.qoi_list)


# %% md
#
# Example 2: Single tri-variate random variable
Expand Down Expand Up @@ -228,13 +228,12 @@

if pick_model == 'vector' or pick_model == 'all':
# Call to RunModel - Here we run the model while instantiating the RunModel object.
# Notice that we do not specify var_names. This will default to a single variable with name x0. In this case,
# we will read them in by indexing in the input_template.
t = time.time()
m = RunModel(samples=x_mcs_tri, ntasks=1, model_script='matlab_model_sum_vector_indexed.py',
input_template='sum_vector_indexed.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model', fmt="{:>10.4f}")
model = ThirdPartyModel(model_script='matlab_model_sum_vector_indexed.py',
input_template='sum_vector_indexed.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
model_dir='Matlab_Model', fmt="{:>10.4f}", var_names=['x0'])
m = RunModel(samples=x_mcs_tri, ntasks=1, model=model)
t_ser_matlab = time.time() - t
print("\nTime for serial execution:")
print(t_ser_matlab)
Expand All @@ -255,13 +254,12 @@

if pick_model == 'vector' or pick_model == 'all':
# Call to RunModel - Here we run the model while instantiating the RunModel object.
# Notice that we do not specify var_names. This will default to a single variable with name x0. In this case,
# we will read them in by indexing in the input_template.
t = time.time()
m = RunModel(samples=x_mcs_tri_list, ntasks=2, model_script='matlab_model_sum_vector_indexed.py',
input_template='sum_vector_indexed.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model')
model = ThirdPartyModel(model_script='matlab_model_sum_vector_indexed.py',
input_template='sum_vector_indexed.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
model_dir='Matlab_Model', var_names=['x0'])
m = RunModel(samples=x_mcs_tri_list, ntasks=2, model=model)
t_ser_matlab = time.time() - t
print("\nTime for parallel execution:")
print(t_ser_matlab)
Expand All @@ -285,18 +283,18 @@
# Notice that we do not specify var_names. This will default to a single variable with name x0. In this case,
# we will read them in by indexing in the input_template.
t = time.time()
m = RunModel(samples=x_mcs_tri, ntasks=1, model_script='matlab_model_sum_vector.py',
input_template='sum_vector.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model', fmt="{:>10.4f}")
model = ThirdPartyModel(model_script='matlab_model_sum_vector.py',
input_template='sum_vector.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
model_dir='Matlab_Model', fmt="{:>10.4f}", var_names=['x0'])
m = RunModel(samples=x_mcs_tri, ntasks=1, model=model)
t_ser_matlab = time.time() - t
print("\nTime for serial execution:")
print(t_ser_matlab)
print()
print("The values returned from the Matlab simulation:")
print(m.qoi_list)


# %% md
#
# Example 3: Passing a scalar and an array to RunModel
Expand Down Expand Up @@ -388,10 +386,11 @@
# case, x0 is a scalar and x1 is a 3x3 matrix. We will read the matrix in without indexing in the
# input_template.
t = time.time()
m = RunModel(samples=x_mixed_array, ntasks=1, model_script='matlab_model_det.py',
input_template='prod_determinant.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model', fmt="{:>10.4f}")
model = ThirdPartyModel(model_script='matlab_model_det.py',
input_template='prod_determinant.m', model_object_name="matlab", var_names=['x0', 'x1'],
output_script='process_matlab_output.py', output_object_name='read_output',
model_dir='Matlab_Model', fmt="{:>10.4f}")
m = RunModel(samples=x_mixed_array, ntasks=1, model=model)
t_ser_matlab = time.time() - t
print("\nTime for serial execution:")
print(t_ser_matlab)
Expand All @@ -412,14 +411,13 @@

if pick_model == 'mixed' or pick_model == 'all':
# Call to RunModel - Here we run the model while instantiating the RunModel object.
# Notice that we do not specify var_names. This will default to two variables with names x0 and x1. In this
# case, x0 is a scalar and x1 is a 3x3 matrix. We will read the matrix in with indexing in the
# input_template.
# We will read the matrix in with indexing in the input_template.
t = time.time()
m = RunModel(samples=x_mixed_array, ntasks=1, model_script='matlab_model_det_index.py',
model = ThirdPartyModel(model_script='matlab_model_det_index.py',
input_template='prod_determinant_index.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model', fmt="{:>10.4f}")
model_dir='Matlab_Model', fmt="{:>10.4f}", var_names=['x0', 'x1'])
m = RunModel(samples=x_mixed_array, ntasks=1, model=model)
t_ser_matlab = time.time() - t
print("\nTime for serial execution:")
print(t_ser_matlab)
Expand All @@ -442,14 +440,12 @@

if pick_model == 'mixed' or pick_model == 'all':
# Call to RunModel - Here we run the model while instantiating the RunModel object.
# Notice that we do not specify var_names. This will default to two variables with names x0 and x1. In this
# case, x0 is a scalar and x1 is a 3x3 matrix. We will read the matrix in without indexing in the
# input_template.
t = time.time()
m = RunModel(samples=x_mixed, ntasks=2, model_script='matlab_model_det.py',
model = ThirdPartyModel(model_script='matlab_model_det.py',
input_template='prod_determinant.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model')
model_dir='Matlab_Model', var_names=['x0', 'x1'])
m = RunModel(samples=x_mixed, ntasks=2, model=model)
t_ser_matlab = time.time() - t
print("\nTime for serial execution:")
print(t_ser_matlab)
Expand Down Expand Up @@ -477,10 +473,11 @@
# case, x0 is a scalar and x1 is a 3x3 matrix. We will read the matrix in with indexing in the
# input_template.
t = time.time()
m = RunModel(samples=x_mixed, ntasks=2, model_script='matlab_model_det_index.py',
model = ThirdPartyModel(model_script='matlab_model_det_index.py',
input_template='prod_determinant_index.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model')
model_dir='Matlab_Model', var_names=['x0', 'x1'])
m = RunModel(samples=x_mixed, ntasks=2, model=model)
t_ser_matlab = time.time() - t
print("\nTime for serial execution:")
print(t_ser_matlab)
Expand Down Expand Up @@ -508,13 +505,14 @@
# case, x0 is a scalar and x1 is a 3x3 matrix. We will read the matrix in with indexing in the
# input_template.
t = time.time()
m = RunModel(samples=x_mixed_array, ntasks=1, model_script='matlab_model_det_partial.py',
model = ThirdPartyModel(model_script='matlab_model_det_partial.py',
input_template='prod_determinant_partial.m', model_object_name="matlab",
output_script='process_matlab_output.py', output_object_name='read_output',
resume=False, model_dir='Matlab_Model', fmt="{:>10.4f}")
model_dir='Matlab_Model', fmt="{:>10.4f}", var_names=['x0', 'x1'])
m = RunModel(samples=x_mixed_array, ntasks=1, model=model)
t_ser_matlab = time.time() - t
print("\nTime for serial execution:")
print(t_ser_matlab)
print()
print("The values returned from the Python simulation:")
print(m.qoi_list)
print(m.qoi_list)
Loading

0 comments on commit 8ea79d1

Please sign in to comment.