This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

WaterObejct SDK: how can I create a child scenario?

Hello,

I am new to waterObject and I am trying to create a child scenario (from the active scenario). At the moment, the only thing I have managed to create is a new base scenario using the DomainDataSet.ScenarioManager.Add().

How can I create a child scenario instead? (so that all properties/characteristics are already based on the parent scenario?)

I was hoping there was an easy way to do this, but, if there is, I cannot find it. Any help is really appreciated.

Thank you very much in advance,

Kind regards,

Angela

  • Hi Angela,

    Adding a child scenario is technically simple but there are a few things that need to be done after adding the child scenario.

    IDomainDataSet domainDataSet = GetDomainDataSet();
    IScenarioManager scenarioManager = domainDataSet.ScenarioManager;
    
    //Use the alternatives assigned to the first base scenario as
    //the alternatives for the new alternative if a new base scenario
    IScenario baseScenario = (IScenario)scenarioManager.Elements()[0];
    
    int id = scenarioManager.Add();
    IScenario child = (IScenario)scenarioManager.Element(id);
    
    //parentID is the ID of the parent scenario.
    //Leave this property 0 to make it a base scenario.
    child.ParentID = parentID;
    
    //This part is important to make sure alternatives are marked as
    //inherited for the new child scenario.
    
    AlternativeTypeCollection alternativeTypes = domainDataSet.DomainDataSetType().AlternativeTypes();
    for (int i = 0; i < alternativeTypes.Count; ++i)
    {
        if (child.ParentID > 0)
            child.MakeAlternativeInherited(alternativeTypes[i].Id);
        else
            child.AlternativeID(alternativeTypes[i].Id,
                baseScenario.AlternativeID(alternativeTypes[i].Id));
    }
    
    //It is also important to mark calculation options inherited as well.
    
    NumericalEngineTypeCollection engineTypes = domainDataSet.DomainDataSetType().NumericalEngineTypes();
    
    for (int i = 0; i < engineTypes.Count; ++i)
    {
        if (child.ParentID > 0)
            child.MakeCalculationOptionsInherited(engineTypes[i].Name);
        else
            child.CalculationOptionsID(engineTypes[i].Name,
                baseScenario.CalculationOptionsID(engineTypes[i].Name));
    }

    If you have any questions, please ask.

    Kris Culin
    Senior Software Developer
    Water Infrastructure
    Bentley Systems, Inc.

    Answer Verified By: Larry Abla 

  • Angela,
     
    Kris Culin from our development team sent you some tips on how to proceed.
     
    Who are you working for now? Are you a post doc at the University?
     
    What problem are you trying to solve in your current project?
     
    Best wisehs,
     
    Tom
     
  • Hi Angela,

    I've summarized Kris's comments in this Wiki article - WaterObjects.NET - How can I create a child scenario?

    Thank-you,
    Larry

  • Thank you very much, Kris! It makes sense now, but I don't think I would have been able to do it myself.

    Thank you very much again.

    Kind regards,

    Angela

  • Hello Tom,

    I hope you are well and thank you very much for your email.

    I am not a post Doc at the University anymore. I have been working for SA Water (South Australia Water Corporation, the water utility in South Australia) in Adelaide since the beginning of the year.

    Part of my team's job is to assess applications (e.g. new connections, inline fire pumps etc.). For some of the transient analysis, it would be very helpful to be able to automatically set the initial conditions of a subset of the network (e.g. every node within a certain distance from the transient generation point). Most models cover a large area and have hundred of thousands of nodes: most of these nodes are not affected by a relatively small transient generated far enough and 'cutting' the network will make the computations much faster.

    What I would like to do is basically run an EPS simulation with a given demand in one node, choose the results of a specific time step, assign the demands of that particular time step to the nodes within a certain distance and create fictitious boundary conditions (e.g. a storage). (ideally repeat the process with a larger distance and see if the results are still similar).

    Another application is to (pre-)assess potential connections in some parts of the network(s), so that the applications can be processed more quickly (if there is enough capacity in the system).

    Please, let me know if you need additional details. I think what I am trying to achieve is strictly related to the type of output needed by SA Water, which could be different from what other water utilities do.

    Thank you very much again,

    Kind regards,

    Angela