Posted Mon, 27 Jun 2016 18:44:27 GMT by Luis Camilo Casallas Student
Hi guys,
I try to generate a random of parameters in my model (specially K) for see the comportement with differents scenarios. But I can do it automatically how is possible in Processing Modflow - pmwin.
Can you give please  some idea to do the formulas in the expression editor or external code?
Thank you for your help!
Posted Wed, 29 Jun 2016 15:11:24 GMT by Björn Kaiser
Are you sure that you only want to create random parameter fields without optimizing the parameters (PEST/FePEST)?
Posted Thu, 30 Jun 2016 21:47:57 GMT by Luis Camilo Casallas Student
Thanks Björn Kaiser for your answer. I dont use Fepest for this situation.

I see this code that is a good option for generation random of the parameters "http://m2matlabdb.ma.tum.de/download.jsp?MC_ID=5&MP_ID=31" but I would like to know if in feflow, I can do it with the expression editor or I need a plug-in or what is your recomendation for do it?

I try to simulate an anisotropy in the model with random values of K with each element and I interpolated the values with the Feflow method but this did not work.
See in... https://www.dropbox.com/s/scp5fsvtjf92s46/image.JPG?dl=0

Posted Mon, 04 Jul 2016 11:43:12 GMT by Björn Kaiser
A random parameter field generator within FEFLOW is planned for the future. It has not been developed yet.

Accordingly, you need to use an external generator like the one you indicated. You could use the output of the generator as input in FEFLOW to parametrize your model.

One option is to convert the generator output into the ASCII based dat-file format readable by FEFLOW. This file can be used as a map for parameter linking (regionalization). The disadvantage is the manual work. I would expect that this task is tedious and time-consuming particularly if you have to carry out a large number of simulations.

Another possibility is the development of a script (Python) or plugin (C/C++). I suggest to use Python, where Kernel Control Methods are provided. Generally, Kernel control methods enable the user to start/stop the kernel, to load/save documents, and to control the simulation. You could use kernel control method [font=courier][color=blue]doc.startSimulator()[/color][/font] to start the simulator within a loop ranging from 0 to n_number_of_simulations-1. Before you start the simulator you could assign the random parameter field to the mesh elements

In this context, please note that available regionalization methods are not available for Python. Instead you need to assign the K-values via
[font=courier][color=blue]
extern void IfmSetMatXConductivityValue3D (IfmHandle, int, double);
extern void IfmSetMatYConductivityValue3D (IfmHandle, int, double);
extern void IfmSetMatZConductivityValue3D (IfmHandle, int, double);
[/color][/font]

You could derive the K-values of each element by taking advantage of using the FEFLOW API and GIS API (e.g. arcpy) within a single script. Since the mesh do not change over time (I assume you do not use the free & moveable method) you need to export the element centroids as a point shapefile from the Data panel only one time (not from the script).

Within each loop you may convert the parameter field into a GIS raster file or TIN (Triangulated Irregular Network). To transfer (project) the K-values of the raster / TIN to the shapefile attributes you could use the arcpy function [font=courier][color=blue]AddSurfaceInformation_3d (in_feature_class, in_surface, out_property, {method}, {sample_distance}, {z_factor}, {pyramid_level_resolution}, {noise_filtering})[/color][/font]. In former times, the function was also called Surface Spot.

After the K-values are written to the input feature's attribute table you may use the FEFLOW API function [font=courier][color=blue]IfmFindElementAtXYZ (IfmHandle, double x, double y, double z);[/color][/font] to derive the element ID's which correspond to the points. As soon you derived the element ID you may finally assign the K-value based on the three assignment functions I have shown above.

In general the workflow seems a bit complicated, but the script would only have a few lines of code.
Posted Mon, 04 Jul 2016 17:22:57 GMT by Björn Kaiser
The functions I have shown above are formulated in C/C++, but can be easily adopted in Python. Please let me know if you have further questions.
Posted Fri, 29 Jul 2016 01:14:47 GMT by Luis Camilo Casallas Student
Thanks Björn Kaiser, I'll try to do it
Posted Mon, 15 Nov 2021 09:50:53 GMT by Razi Sadath P V Senior Research Fellow
im using feflow 7.0 please help me on how to use pyhton or ifm?
Posted Tue, 16 Nov 2021 06:34:58 GMT by Peter Schätzl Grundwassermodellierer
You can find a tutorial for using IFM in the FEFLOW help: http://www.feflow.info/html/help74/feflow/13_Programming/tutorial_ifm.html
The use of the Python interface is also described in the help system. Note that FEFLOW 7.0 did not have a python interpreter in the FEFLOW GUI, but you could use Python via the command-line interface or by loading FEFLOW as a module in your own python code (I'd recommend the latter). The help also contains some examples.

You must be signed in to post in this forum.