groovyBC and probe measurement
Hi,
I'm trying to use groovyBC to implement closed-loop control in a simulation. I have a probe (in the controlDict) set to record a pressure measurement at a particular position in the geometry, and wish to use this value in conjunction with groovyBC to perform some maths operation on the value of pressure at the probe at each timestep, and use this value to update the value of a particular boundary condition for the next timestep. So far my thinking takes me thus far: Code:
actuatorBoundary Thanks a lot, Olie |
Quote:
|
Quote:
Okay so after some more reading and re-reading I think, after I've got a cloud sample correct, the groovyBC boundary in the 0/U file should look something like this: Code:
actuator Thanks again, Olie ****EDIT**** Oh no - found some documentation on using cloud and it appears you can only use this in sampleDict - so now I'm confused.. How do I use this during runtime so it samples (like a probe) at each time step such that groovyBC can then use the value? |
Quote:
|
Quote:
Code:
functions Code:
expressions ( Field p does not exist From function Foam::readAndUpdateFields::read(const dictionary& dict) in file misc/readAndUpdateFields/readAndUpdateFields.C at line 128. FOAM exiting What am I doing wrong? Thanks again, Olie |
:( ? Anyone?
|
Working (I think) but strange results.
I believe I've got it working now - I put this in the functions section of the controlDict:
Code:
createMeasurement Code:
actuator I think it's *close* to working, but not quite. The attached image (hope the attaching works) shows the sampled pressure from sensor1, p_wall, the velocity on the actuator boundary v_act, and the ratio of p_wall to v_wall, which *should* be 100, given groovyBC is set to give v_act=0.01*p_wall, but it's more like 200. Am I doing something wrong? Thanks! http://oi57.tinypic.com/2nbve3a.jpg |
Quote:
BTW: just to be sure make it "pressureMeasurement{set'sensor1}=average( p );" (I think otherwise it might break in parallel) |
Quote:
Code:
actuator_velocity Oh thank you I'll put in average(). Also, can you use matrices in groovyBC expressions? Similar to how you can use vectors somehow? If so how do you do this? Thanks a lot. |
Also...
Also, I'm using some storedVariables for a boundary condition, which update themselves each timestep, something like storedVariable1 = 0.5*storedVariable1 (there's more to it, but that's the general idea). However my thinking is that it updates the value of the variable every computational timestep which is a variable time step - I only want it to update at every write interval - so how do I specify that it's only to update at, for example, every 0.5 seconds? NOT ever actual computational time step?
Thanks a lot again, Olie |
Quote:
matrixes are called tensors (3x3). swak supports all the operations on them OF supports (see the programmers-guide) |
Quote:
You want your storedVariable1 to "decay" exponentially, right? A bit of fiddling around with deltaT() and exp() will give you a decay with the same rate (it is year 1 mathematics. So don't ask me for formulas. I don't want to embarrass myself) |
Quote:
No that was just an example of the manner in which I'm wanting to use storedVariables - what I'm trying to do with them is actually more complicated, using them as state values for a discrete time state-space controller. But this shouldn't matter - the point is I need it to only update storedVariables at certain times: the times when data is written. Correct the solution will depend on how often it's written - this is CORRECT in my particular situation (don't ask why, unless you're really interested!). So is this possible? Thank you for all your help so far! I dare say I'm at the final hurdle! |
Quote:
General swak-Expressions have no function "outputTime()" that is true for times when OF does output (for the reasons above). What DOES have such a variable is the Python-integration |
Quote:
Thanks, Olie |
Quote:
|
Quote:
My guess is to put something like this in controlDict: Code:
defineState { If it helps, the attached image shows what I'm trying to implement - note that state values x do not refer to some physical state (such as pressure, velocity etc), they're just values that are updated at each write interval according to x_k+1 = Ax_k + Bs_k, and in the image when I refer to 'timestep' I also mean write interval, i.e. some fixed interval (in my case 0.5 seconds). Thanks http://i.imgur.com/G6zEvin.png |
Quote:
Anyway: For the meaning of value etc see http://openfoamwiki.net/images/c/c0/...rogrammers.pdf starting at page 30. A few pages later calculateGlobalVariables is explained (which would be how you get the sensor values). The groovyBC then will only have to get the global variables (that is also explained there) |
All times are GMT -4. The time now is 08:21. |