Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
lpossner committed Oct 1, 2023
2 parents c8d61fc + 75eeef7 commit 8c48614
Show file tree
Hide file tree
Showing 37 changed files with 2,104 additions and 585 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ tags

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
Expand Down
1 change: 0 additions & 1 deletion doc/examples/algorithms/plot_algorithm_mestatic_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def deq(rho, t, alpha, beta, gamma):
n_grid=[100, 100],
coords=grid.coords,
results=results,
fn_out=None,
camera_pos=[45., 65])

# On Windows subprocesses will import (i.e. execute) the main module at start.
Expand Down
14 changes: 7 additions & 7 deletions doc/examples/algorithms/plot_algorithm_mestaticprojection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
# gPC options
options = dict()
options["method"] = "reg"
options["solver"] = "Moore-Penrose"
options["solver"] = "LarsLasso"
options["settings"] = None
options["order"] = [3, 3]
options["order_max"] = 3
options["order"] = [5, 5]
options["order_max"] = 5
options["interaction_order"] = 2
options["n_cpu"] = 0
options["gradient_enhanced"] = True
options["gradient_calculation"] = "FD_fwd"
options["gradient_calculation_options"] = {"dx": 0.001, "distance_weight": -2}
# options["gradient_enhanced"] = False
# options["gradient_calculation"] = "FD_fwd"
# options["gradient_calculation_options"] = {"dx": 0.001, "distance_weight": -2}
options["error_type"] = "nrmsd"
options["n_samples_validation"] = 1e3
options["qoi"] = "all"
Expand All @@ -52,7 +52,7 @@
options["save_session_format"] = save_session_format
options["grid"] = pygpc.Random
options["grid_options"] = {"seed": 1}
options["n_grid"] = 1000
options["n_grid"] = 2000
options["adaptive_sampling"] = False

# define algorithm
Expand Down
16 changes: 13 additions & 3 deletions doc/examples/algorithms/plot_algorithm_static_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
options["backend"] = "omp"
options["verbose"] = True

# determine number of gPC coefficients (hint: compare it with the amount of output data you have)
n_coeffs = pygpc.get_num_coeffs_sparse(order_dim_max=options["order"],
order_glob_max=options["order_max"],
order_inter_max=options["interaction_order"],
dim=len(parameters))

# define algorithm
algorithm = pygpc.Static_IO(parameters=parameters, options=options, grid=grid, results=results)

Expand Down Expand Up @@ -87,15 +93,19 @@
calc_pdf=True,
algorithm="standard")

# get a summary of the sensitivity coefficients
sobol, gsens = pygpc.get_sens_summary(fn_results, parameters)
print(sobol)
print(gsens)

# plot gPC approximation and IO data
pygpc.plot_gpc(session=session,
coeffs=coeffs,
random_vars=["x1", "x3"],
output_idx= 0,
output_idx=0,
n_grid=[100, 100],
coords=grid.coords,
results=results,
fn_out=None)
results=results)

# On Windows subprocesses will import (i.e. execute) the main module at start.
# You need to insert an if __name__ == '__main__': guard in the main module to avoid
Expand Down
Binary file modified doc/examples/algorithms/tmp/mestaticprojection.hdf5
100755 → 100644
Binary file not shown.
Binary file modified doc/examples/algorithms/tmp/mestaticprojection.pkl
Binary file not shown.
19 changes: 12 additions & 7 deletions doc/examples/examples/plot_Lorenz.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import pygpc
import numpy as np
from collections import OrderedDict
import matplotlib
matplotlib.use("Qt5Agg")

#%%
# At first, we are loading the model:
Expand Down Expand Up @@ -93,23 +95,26 @@
output_idx=None,
calc_sobol=True,
calc_global_sens=True,
calc_pdf=False,
n_samples=int(1e4))
calc_pdf=False)

# extract sensitivity coefficients from results .hdf5 file
sobol, gsens = pygpc.get_sens_summary(fn_gpc=fn_results,
parameters_random=session.parameters_random,
fn_out=fn_results + "_sens_summary.txt")

# plot time course of sensitivity coefficients and mean and standard deviation of x(t)
# plot time course of mean together with probability density, sobol sensitivity coefficients and global derivatives
t = np.arange(0.0, parameters["t_end"], parameters["step_size"])
pygpc.plot_sens_summary(sobol=sobol,
pygpc.plot_sens_summary(session=session,
coeffs=coeffs,
sobol=sobol,
gsens=gsens,
multiple_qoi=True,
plot_pdf_over_output_idx=True,
qois=t,
results=results,
mean=pygpc.SGPC.get_mean(coeffs),
std=pygpc.SGPC.get_std(coeffs),
x_label="t in s",
y_label="x(t)")
y_label="x(t)",
zlim=[0, 0.4])

#
# On Windows subprocesses will import (i.e. execute) the main module at start.
Expand Down
15 changes: 10 additions & 5 deletions doc/examples/examples/plot_Lorenz_julia.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def simulate(self, process_id=None, matlab_engine=None):
import pygpc
import numpy as np
from collections import OrderedDict
import matplotlib
matplotlib.use("Qt5Agg")
# Windows users have to encapsulate the code into a main function to avoid multiprocessing errors.
# def main():
Expand Down Expand Up @@ -162,14 +164,17 @@ def simulate(self, process_id=None, matlab_engine=None):
# plot sobol indices over time and mean and standard deviation of x(t)
t = np.arange(0.0, parameters["t_end"], parameters["step_size"])
pygpc.plot_sens_summary(sobol=sobol,
pygpc.plot_sens_summary(session=session,
coeffs=coeffs,
sobol=sobol,
gsens=gsens,
multiple_qoi=True,
plot_pdf_over_output_idx=True,
qois=t,
results=results,
mean=pygpc.SGPC.get_mean(coeffs),
std=pygpc.SGPC.get_std(coeffs),
x_label="t in s",
y_label="x(t)")
y_label="x(t)",
zlim=[0, 0.4])
"""
import matplotlib.pyplot as plt

Expand Down
6 changes: 4 additions & 2 deletions doc/examples/examples/plot_ishigami.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import pygpc
import numpy as np
from collections import OrderedDict
import matplotlib
matplotlib.use("Qt5Agg")

fn_results = "tmp/example_ishigami"

Expand Down Expand Up @@ -112,8 +114,8 @@
#%%
# Sensitivity analysis
# ^^^^^^^^^^^^^^^^^^^^
sobol, gsens = pygpc.get_sens_summary(fn_results, parameters_random)
pygpc.plot_sens_summary(sobol, gsens)
sobol, gsens = pygpc.get_sens_summary(fn_results, parameters_random, fn_results + "_sens_summary.txt")
pygpc.plot_sens_summary(sobol=sobol, gsens=gsens)

#
# On Windows subprocesses will import (i.e. execute) the main module at start.
Expand Down
Binary file removed doc/examples/examples/tmp/example_ishigami.hdf5
Binary file not shown.
Binary file modified doc/examples/examples/tmp/example_ishigami.pkl
Binary file not shown.
Binary file removed doc/examples/examples/tmp/example_ishigami_mc.hdf5
Binary file not shown.
Binary file modified doc/examples/examples/tmp/example_ishigami_mc_qoi_0.pdf
Binary file not shown.
Binary file modified doc/examples/examples/tmp/example_ishigami_mc_qoi_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions doc/examples/examples/tmp/example_ishigami_sens_summary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Normalized Sobol indices:
==========================
['x2']: 0.442411
['x1']: 0.313905
['x1', 'x3']: 0.243684
['x1', 'x2']: 0.000000
['x2', 'x3']: 0.000000
['x3']: 0.000000

Average derivatives:
==========================
['x1']: 8.47e-06
['x2']: -3.25e-07
['x3']: -1.51e-06
Binary file removed doc/examples/examples/tmp/example_ishigami_val.hdf5
Binary file not shown.
Binary file modified doc/examples/examples/tmp/example_ishigami_val_qoi_0.pdf
Binary file not shown.
Binary file modified doc/examples/examples/tmp/example_ishigami_val_qoi_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/examples/examples/tmp/example_lorenz.hdf5
Binary file not shown.
Loading

0 comments on commit 8c48614

Please sign in to comment.