analysis tools

Monte-carlo analysis

Generic usage of the monte-carlo class:

 1from wandatoolbox.analysis.monte_carlo import MonteCarloInputProperty, MonteCarloOutputProperty, WandaMonteCarlo
 2import pywanda as pw
 3import os
 4
 5def main():
 6    wandacase_fullpath = os.path.join(os.getcwd(), "Sewage_transient.wdi")
 7    wanda_bin_directory = r'c:\Program Files (x86)\Deltares\Wanda 4.6\Bin\\'
 8    model = pw.WandaModel(wandacase_fullpath, wanda_bin_directory)
 9    parameters = [MonteCarloInputProperty(" PIPES", "Wall roughness", 2.5 / 1000, 0.5 / 1000, "normal", True)]
10    outputs = [MonteCarloOutputProperty(" PIPES", "Pressure", keyword=True, extreme="MIN"),
11            MonteCarloOutputProperty(" PIPES", "Pressure", keyword=True, extreme="MAX")]
12    analysis = WandaMonteCarlo(model, parameters, outputs, nruns=25, n_workers=2)
13    analysis.run()
14    analysis.plot_results(filename_prefix="test", width=1000, height=800)
15    analysis.cleanup()
16
17
18if __name__ == "__main__":
19    main()  # This main() method is essential due to the way Python's multiprocessing module works

The monte carlo toolset will run multiple simulation in parallel, greatly reducing the simulation time.