Giter Club home page Giter Club logo

mike1d-sdk-examples's Introduction

MIKE 1D SDK examples

This repository contains a number of examples of Plugins and Scripts for MIKE 1D.

Since MIKE 1D is an active code base, its API changes. The master branch contains example code for the most recent release of MIKE software. Code for older releases can be found in sub-branches.

Content

  • DHI.Mike1D.Examples: Various C# examples of working with MIKE 1D, plugins and scripts.
  • mike1d-rtc-simulator-example: Example wrapper for getting and setting engine variables during simulation.
  • bin: Binaries of MIKE 1D, used for building the DHI.Mike1D.Examples.
  • data: A bit of test data to play around with. Used by the examples in DHI.Mike1D.Examples.
  • m1daExamples: Examples of how to build up a MIKE 1D Additional parameter file, to automatically load and configure plugins.
  • scripts: Scripts in IronPython.

MIKE 1D API

An introduction to the MIKE 1D API can be found on:

http://docs.mikepoweredbydhi.com/engine_libraries/mike1d/mike1d_api/

mike1d-sdk-examples's People

Contributors

gedaskir avatar jespergr avatar pngdhi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mike1d-sdk-examples's Issues

RTC example will not compile

Hello,

Thank you very much for the many example codes, they helped a lot. Unfortunately, I could not compile this particular RTC example.

The following line (line 26, M1DSimulator.cs) is giving me an error:
private Dictionary<string, DDoubleTimeGetter> _catchmentGetters = new Dictionary<string, DDoubleTimeGetter>();

The error I get is:

Error	CS0246	The type or namespace name 'DDoubleTimeGetter' could not be found (are you missing a using directive or an assembly reference?)	DHI.M1DSimulator	C:\PROJECTCODE\Mike1D-SDK-examples\mike1d-rtc-simulator-example\DHI.M1DSimulator\DHI.M1DSimulator\M1DSimulator.cs	26	Active

I think all the assembly references are in the right place. None of the following lines gave me an error:

using System;
using System.Linq;
using System.Collections.Generic;
using DHI.Mike1D.Engine;
using DHI.Mike1D.Generic;
using DHI.Mike1D.RainfallRunoffModule;
using DHI.Mike1D.BoundaryModule;

Mike Urban 2019 to Mike Urban 2020 - Could not load file or assembly 'Antlr4.Runtime, Version=4.4.0.0...'

I recoded M1DSimulatorExample1.m into python 3. This functioned until I installed Mike Urban 2020 and changed the SDK path MIKE_SDK_path = 'C:\\Program Files (x86)\\DHI\\2020\\bin\\'. The error I see after installing Mike Urban 2020 is:

FileNotFoundException                     Traceback (most recent call last)
<ipython-input-2-dcea9bdaa6b6> in <module>
      7 from_dt = System.DateTime(2014, 7, 12, 10, 45, 0)
      8 to_dt = System.DateTime(2014, 7, 12, 10, 55, 0)
----> 9 simulator.PrepareSimulation(from_dt, to_dt)
     10 print(simulator.SimulationStart.Date)

FileNotFoundException: Could not load file or assembly 'Antlr4.Runtime, Version=4.4.0.0, Culture=neutral, PublicKeyToken=bb1075973a9370c4' or one of its dependencies. The system cannot find the file specified.
   at DHI.Math.Expression.MathExpression.Compile()
   at DHI.Mike1D.ControlModule.ControlData.Initialize(Diagnostics parentDiagnostics)
   at DHI.Mike1D.Mike1DDataAccess.Mike1DController.0(Diagnostics A_0)
   at DHI.Mike1D.Mike1DDataAccess.Mike1DController.DoInitialize(IDiagnostics diagnostics)
   at DHI.Mike1D.Mike1DDataAccess.AbstractMike1DController.Initialize(IDiagnostics diagnostics)
   at DHI.M1DSimulator.M1DSimulatorRunner.PrepareSimulation(DateTime from, DateTime to)
   at DHI.M1DSimulator.M1DSimulator.PrepareSimulation(DateTime from, DateTime to)

I have C:\Program Files (x86)\DHI\2020\bin\DHI.Math.Expression.dll - version 18.1.0.14122. According to NuGet, this dll depends on Antlr4.Runtime.Standard (>= 4.7.2). I have C:\Program Files (x86)\DHI\2020\bin\x64\Antlr4.Runtime.Standard.dll - version 4.7.2.
Have you had any issues with Antlr4.Runtime?

For reference, the code looks like this:

import sys
# specify path to the DHI assemblies
MIKE_SDK_path = 'C:\\Program Files (x86)\\DHI\\2020\\bin\\'
sys.path.append(MIKE_SDK_path)
sys.path.append(r'C:\Users\eclark\Documents\GitHub\Mike1D-SDK-examples\mike1d-rtc-simulator-example\Release')
import clr
clr.AddReference('DHI.M1DSimulator')
clr.AddReference('DHI.Mike.Install')
clr.AddReference('System')
# import functions from dlls, etc
from DHI.Mike.Install import MikeImport
import System
import DHI.M1DSimulator
MikeImport.SetupLatest()

# initialize simulator with example case
modelFilePath = r'.\MU\RTCExampleBase.m1dx'
simulator = DHI.M1DSimulator.M1DSimulatorRtc(modelFilePath)

# Add water volume to result file
simulator.SetQuantitiesOfResultSpecification(System.Array[str](['WaterVolume', 'Discharge']))

# Set simulation start and end, print before and after to make sure it worked
print(simulator.SimulationStart.Date)
print(simulator.SimulationEnd.Date)
from_dt = System.DateTime(2014, 7, 12, 10, 45, 0)
to_dt = System.DateTime(2014, 7, 12, 10, 55, 0)
simulator.PrepareSimulation(from_dt, to_dt)
print(simulator.SimulationStart.Date)
print(simulator.SimulationEnd.Date)

Mike1DDataXmlBridge cannot load IDataContractSurrogate on .net 5.0

I get the error message below when trying to run a Mike Urban model using the API, based on a modified version of this code (

)

Capture

It seems to me this is a .NET related issue, since it seems that IDataContractSurrogate is not in .net 5.0 (https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.idatacontractsurrogate?view=netframework-4.8&viewFallbackFrom=net-5.0).

/M

Use MIKE1D SDK with MIKE+

Hi, I'm working on a project with MIKE+. One task is to calibrate the model with six events. As MIKE+ doesn't allow multiple simulations, I'm trying to run it with MIKE1D SDK. The example and document is good but doesn't mention the format of simulation file. If I have the scenario name I want to run, how could I use MIKE1D SDK to run the simulations? Do I need to create the simulation files? I'd appreciate your help.

Mike Urban Plus - user written controls -SQLite

Thanks for providing this set of Mike1D SDK examples. We're transitioning to Mike Urban Plus and looking to transition our user-written controls to the new framework. I have noticed that the examples in this repo use the *.m1dx file as a basis for updating the model simulations. In my experience so far, Mike Urban Plus does not write an *.m1dx file but presumably works from the SQLite database directly. Do you know of any examples for interacting directly with Mike1D in the Mike Urban Plus framework? Is anyone working on this? Or does the DHI.M1DSimulator.M1DSimulatorRtc() function work with a SQLite file as well?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.