Comments (6)
@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.
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.
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.
And a 2nd issue is to create the solver before the storages - the solver contains only the statevariables given on creation.
from cmf.
@richardneumann84 , any progress on this? Otherwise i am going to close this issue at the end of the week.
from cmf.
@richardneumann84 would this structure tutorial have prevented you from the mistake above?
from cmf.
Related Issues (20)
- Describe how to build a custom cmf
- Update Docs with new Solver names HOT 1
- Run CVodeKLU with CUDA
- Setup.py build libraries on clean command
- Freundlich Adsorption not working
- Can't create a SoluteWaterIntegrator HOT 1
- new flux: Schmitt-trigger HOT 4
- make potential of Dirichlet BC a time series HOT 1
- Undefined behaviour when c'tor of flux_connection throws HOT 2
- Remove integratables HOT 1
- CVodeKLU is not suitable in a SoluteWaterIntegrator HOT 1
- Add additional ET method with parameterized aerodynamic resistance HOT 5
- Diffusive singularity protection is inconsistent HOT 1
- cmf.timeseries should get a from_pandas factory function HOT 2
- Modernize the doxygen documentation HOT 1
- Allow for Python flux connections, even if they are slow HOT 1
- Simple infiltration ignores waterbalance connections regardless of their direction
- Try out scikit-build with ninja for CMF 2.0
- Update CVODE
- error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmf.