• Re: Programmatically Read/Write Dfs0 files

    Hi again,

    I've just tried to use a C# programme (which uses those two dll files mentioned above) to read and write a dfs0 file and it worked perfectly in demo mode. The dfs0 file contains 4 items and 1050 time steps.

    So, i think the problem is not the Mike license. Can you describe in more details your problem ?

    Regards,
    Aurelian
  • Re: Programmatically Read/Write Dfs0 files

    Hello,

    There is no specific API for handling dfs0 files, as it is written in the documentation ("DFS_UserGuide.pdf"), but the good news is that you can manage dfs0 files by using [i]DfsFileFactory[/i] class. You also must use the [i]IDfsFile[/i] interface which provides functionality for reading and writing any dfs file.

    Example (C#):
    // Open the [i]filename.dfs0[/i] file in edit mode.
    IDfsFile dfs0File = DfsFileFactory.DfsGenericOpenEdit("filename.dfs0");

    // Header information is contained in the IDfsFileInfo.
    IDfsFileInfo fileInfo = dfs0File.FileInfo;

    // Get the number of items and the number of time steps.
    int noItems = dfs0File.ItemInfo.Count;
    int noTimeSteps = fileInfo.TimeAxis.NumberOfTimeSteps;

    //Lets assume that the data are stored as floats.
    IDfsItemData<float> data;
    float[,] values = new float[noItems, noTimeSteps];

    // Iterate throw all the time steps in all the items,
    // multiply each value by 2 and store them in the [i]values[/i] matrix.
    for (int i = 0; i < noTimeSteps; i++)
        for (int j = 1; j <= noItems; j++)
        {
            data = (IDfsItemData<float>)dfs0File.ReadItemTimeStep(j, i);
            values[j - 1, i] = Convert.ToSingle(data.Data[0] * 2);
        }

    // Write the updated values.
    for (int i = 0; i < noTimeSteps; i++)
        for (int j = 1; j <= noItems; j++)
        {
            dfs0File.WriteItemTimeStep(j, i, 0, new float[] { values[j - 1, i] });
        }

    dfs0File.Close();
    //The End

    I suggest you to analyze the example located at "...\DHI\2012\MIKE Zero\Manuals\MIKE_ZERO\FileFormats\Examples\CSharp\ExamplesDfs0.cs" and also the documentation.

    Regards,
    Aurelian
  • Re: Programmatically Read/Write Dfs0 files

    Hi again,

    I've just find where are located the files I need for managing dfs files:
    "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\DHI.Generic.MikeZero.DFS\v4.0_13.0.0.0__c513450b5d0bf0bf\DHI.Generic.MikeZero.DFS.dll"
    "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\DHI.Generic.MikeZero.EUM\v4.0_13.0.0.0__c513450b5d0bf0bf\DHI.Generic.MikeZero.EUM.dll"

    I'm very happy about my first dfs0 file created programmatically! It seems like Mike11, but not only this Mike product, can be integrated in other softwares as an engine. You can read and write all the Mike11 input files and you can read the results files (*.res11) using "res11read.exe" tool.

    Bye,
    Aurelian
  • Programmatically Read/Write Dfs0 files

    Hello everyone,

    I am interested in reading and writeing dfs0 files at programming level. This will help me to adjust the time series using Auto Calibration tool (AUTOCAL) and for another purposes.

    After I made some reserch on the Mike documentation, i found out this pdf file: "...\DHI\2012\MIKE Zero\Manuals\MIKE_ZERO\FileFormats\DFS_UserGuide.pdf". I was very glad to see that there is a .NET API for reading, modifying and creating DFS files. Unfortunatly, in my Mike 2012 Bin folder the "DHI.Generic.MikeZero.DFS.dll" file is missing.

    1. In case you have Mike 2012 installed, do you have this file ?
    2. Do you know any application tool to convert a time series stored in an ASCII file into a dfs0 ?

    Thanks,
    Aurelian
  • Re: Merge two network files

    Hello,

    Please find attached an example of how to merge two network files and two boundary files.

    1. Change the extension of the attachment file from .txt to .rar.
    2. Extract the folder on your computer.
    3. Change the paths, in the pfsMerge.bat file, accordingly to your folder location.

    Regards,
    Aurelian
  • Re: Merge two network files

    Dear Mr. Torben,

    Thank you for your response. I didn't know about pfsmerge.exe utility program and about that feature from Mike11 Network Editor called 'Number Points Consecutively'.

    In fact, the first time I didn't do everything manually, I created a small program which adds an integer to all points number and after I combined all the elements into one file. So, I took care to avoid the overlaping of the numbering of internal points. Finaly, the network file worked very well. There was no problem with the network file itself, the problem occured when I tried to run the simulation file.

    Anyway, after your message, I tried to start from the original files and I followed the steps you described above. The result is that the pfsmerge.exe gives the next message:
    "
    Loading xx.nwk11 ...
    Error when opening xx.nwk11
    Program Halt 1
    "

    So, thank you very much for your answer which responded perfectly to the third question, but I think I still have the first two questions unanswered:
    1) Did you encounter this error: "Access violation at adress .... in module 'mike11.exe'. Read of address ...." ?
    2) What exactly those processes do: a) "Allocate and assign grid" and "Allocate node cross sections" ?

    Thanks and Regards,
    Aurelian
  • Merge two network files

    Hello everybody,

    I have recived two mike11 models for two consecutive sectors of a river. I merged the network files manually using a text editor. The network file works just fine when I open it with Mike Zero GUI. I also combined the cross-sections files and I made the necessary changes in the Boundary and HD Param. files.

    The problem is that I recive an error when I try to run the simmulation. It's a Mike 11 Engine error with this message: Access violation at adress 0000000000682B75 in module 'mike11.exe'. Read of addressFFFFFFFFFFFFFFF8.

    I have to mention that this windows pops up when the process of "Allocate node cross sections (75639 Kb)"  is being started.

    1. Did anyone face this problem ?
    2. What exactly those processes do: a) "Allocate and assign grid (41113 Kb)" and "Allocate node cross sections (75639 Kb)" ?
    3. Do you know another method to combine two Mike11 models ?

    Thank you,
    Aurelian
  • Re: Mike 11 reservoirs and spillways

    Hello ransara,

    Thank you for your effort. I understand that the structure type "Side structure + reservoir" is not an option if you want to model a dam and its reservoir, because this is a frontal structure and not a side structure.

    Thank you again,
    Aurelian
  • Re: Mike 11 reservoirs and spillways

    Hi ransara,

    Thank you for your answer. I chosen "Side structure + reservoir" because only this type of structure allows you to introduce the storage curve of the reservoir.

    As I said, a simple example of how to model a dam with a reservoir and its operational rules would be priceless.

    Have a nice day,
    Aurelian
  • Re: Mike 11 reservoirs and spillways

    Hello everyone,

    I have to introduce a reservoir in a model type Mike 11 and also the operation rules of the control structures.

    The question is: which structures should I use?

    I tried to make use of "Control Str." from Notwork file -> Structures, and I chosen "Side structure + reservoir" as Structure Type, "Overflow" as Gate Type and set up all the necessary parameters. The result was that almost all amount of water went downstream the structure and a little amount of water went in my reservoir. This seems more like a control structure for a polder or an effective side structure.

    I also tried  to combine a "Control Str." structure with a "Weir" structure, in order to obtain an ineffective flow area, but it didn't worked at all!

    I ask you, because i didn't find something on the internet regarding how to model a reservoir in Mike 11 neither a simple example(which would be very very useful). DHI provides only the user manual for this topic, and I think that is not enough.

    Regards,
    Aurelian