.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery_examples/Permeability_calibration_small/make_calibration_permeability_2D.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_examples_Permeability_calibration_small_make_calibration_permeability_2D.py: 2D permeability field calibration ################################# .. GENERATED FROM PYTHON SOURCE LINES 5-47 .. code-block:: Python import numpy as np from HydrOpTop.Functions import Reference_Liquid_Head #objective from HydrOpTop.Functions import Volume_Percentage #constrain from HydrOpTop.Materials import Log_SIMP from HydrOpTop.Crafter import Steady_State_Crafter from HydrOpTop.Filters import Density_Filter from HydrOpTop.Solvers import PFLOTRAN #create PFLOTRAN simulation object pflotranin = "pflotran.in" sim = PFLOTRAN(pflotranin) #get cell ids in the region to optimize and parametrize permeability #same name than in pflotran input file perm = Log_SIMP(cell_ids_to_parametrize="all", property_name="PERMEABILITY", bounds=[1e-14, 1e-12], power=1) #define cost function as sum of the head in the pit cell_ids = [444, 789, 920, 1030, 1339] head = [230, 250, 227, 146, 210] cf = Reference_Liquid_Head(head, cell_ids, norm=2) #define maximum volume constrains #max_vol = Volume_Percentage("parametrized_cell") #max_vol.constraint_tol = 0.2 filter_ = Density_Filter(10.) #craft optimization problem #i.e. create function to optimize, initiate IO array in classes... crafted_problem = Steady_State_Crafter(cf, sim, [perm], [], [filter_]) crafted_problem.IO.output_every_iteration(1) crafted_problem.IO.output_gradient() crafted_problem.IO.output_material_properties() crafted_problem.IO.define_output_format("vtu") #initialize optimizer p = np.zeros(crafted_problem.get_problem_size()) + 0.5 #p = 0.999*np.random.rand(crafted_problem.get_problem_size())+0.001 p_opt = crafted_problem.optimize(optimizer="nlopt-mma", action="minimize", max_it=100, ftol=0.0001, initial_guess=p) .. _sphx_glr_download_gallery_examples_Permeability_calibration_small_make_calibration_permeability_2D.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: make_calibration_permeability_2D.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: make_calibration_permeability_2D.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_