Coder Social home page Coder Social logo

Comments (6)

philippkraft avatar philippkraft commented on June 12, 2024

@richardneumann84, can you post here a complete, running example and the error message? From your issue I can not tell you what the problem is exactly. One problem I do spot is that you are using the binary XOR-operator ^ at a place where I would expect the power operator **.

Please check your example before posting, if it behaves as expected in a new interactive command line. And please explain, what you want to accomplish with external_control_connection. Sometimes cmf users try solve their problem with the wrong tool.

from cmf.

richardneumann84 avatar richardneumann84 commented on June 12, 2024

Using the following code I recognize that cmf_external_control_connection does not dynamically query the actual state from every time-step - I wish it would.
And target1.volume does not respond to the incoming flux.

from matplotlib import pyplot as pl
from pylab import *
import cmf as cmf
from datetime import datetime,timedelta
project = cmf.project()
cell = project.NewCell(x=0,y=0,z=0,area=1000, with_surfacewater=True) 
cell.surfacewater_as_storage()
solver = cmf.CVodeIntegrator(project,1e-7) 
solver.t = cmf.Time(1,11,2006) 
start = datetime(2006, 11, 1)
end = datetime(2007, 11, 1)

##create new storages:
target1 = project.NewStorage("target1", 0,0,0)
target2=project.NewStorage("target2", 0,0,0)
sw = cell.surfacewater
sw.volume=10000
cmf.external_control_connection(sw,target1,0.01*sw.volume** + 0.01*sw.volume)
print(target1.connections)
##what to save while run:
vol_sw=[]
vol_target1=[]
sw_target1=[]
wb_target1=[]
wb_sw=[]


for t in solver.run(start, end, cmf.day): 
    vol_sw.append(sw.volume)
    vol_target1.append(target1.volume)
    sw_target1.append(sw.flux_to(target1,t))
    wb_target1.append(target1.waterbalance(t))
    wb_sw.append(sw.waterbalance(t))
    
    
plot(vol_target1,label='volume target1')
plot(vol_sw,label='volume surfacewater')   
legend(loc='right')  
show()

plot(sw_target1,label='flux surfacewater to target1')
plot(wb_target1,label='waterbalance target1')
plot(vol_target1,label='volume target1')
legend(loc='right')
show()

from cmf.

philippkraft avatar philippkraft commented on June 12, 2024

I am still unsure, what you would like to do and what function you are expecting from the external control connection. The external part means, that some state / process outside of your cmf model controls your flux - it is a very special connection and is only used if you have some second model, or as written in the docs:

Flux from one node to another, controlled by the user or an external program, by changing the flux constant.

A typical use case is a rule regulated dam.

From your code I guess you want to have a "normal" connection, controlled by an internal state in the form:

q = k * V**2 + k * V

I am sorry, there is until now no flow connection in that form. If you have a scientific need for that formulation or you can send me a reference where this formula has been used, I can implement your approach quite simple as a new connection in the C++ code. And it would need a name :-).

I see, that this formulation differs from the PowerLawConnection, but have you read already the tutorial on kinematic waves?

For starting, I would recommend to stick to connections used in the tutorials, functionality not covered by a tutorial is always experimental.

from cmf.

philippkraft avatar philippkraft commented on June 12, 2024

And a 2nd issue is to create the solver before the storages - the solver contains only the statevariables given on creation.

from cmf.

philippkraft avatar philippkraft commented on June 12, 2024

@richardneumann84 , any progress on this? Otherwise i am going to close this issue at the end of the week.

from cmf.

philippkraft avatar philippkraft commented on June 12, 2024

@richardneumann84 would this structure tutorial have prevented you from the mistake above?

from cmf.

Related Issues (20)

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.