|
| 1 | +// Examples of how SCG/Jinja2 is used in config files. Asumes that all sources are defined in the SCG config file (.yaml) |
| 2 | + |
| 3 | + |
| 4 | +// Conditional logic |
| 5 | +// Conditional attriute value |
| 6 | + |
| 7 | + Evr: Temperature |
| 8 | + Text1= "" |
| 9 | + Meas= {{ TempInit if sim else 0 }} |
| 10 | + |
| 11 | +// Conditional object creation |
| 12 | +{% if Producer %} |
| 13 | + Evr: TempInit |
| 14 | + Text1= "" |
| 15 | + Meas= 100 |
| 16 | +{% endif %} |
| 17 | + |
| 18 | +// For loops |
| 19 | +// Creating multiple variables |
| 20 | +{% for Wellname in wells | unpack("Wellname") %} |
| 21 | + Tvr: {{ Wellname }}Temperature |
| 22 | + Text1= "" |
| 23 | + Meas= 0 |
| 24 | + |
| 25 | +{% endfor %} |
| 26 | + |
| 27 | +// Setting attriute values based on for loop |
| 28 | + XvrMatrix: AUTOWELL |
| 29 | + Row= 4 |
| 30 | + Col= 1 |
| 31 | + RowSize= 7 |
| 32 | + ColSize= 2 |
| 33 | + Heading= "Downhole Pressure" |
| 34 | + ColIds= 3 |
| 35 | + "Setpoint" "Meas" "High" |
| 36 | + RowIds= {{ wells | length}} {# noqa: E301 #} |
| 37 | + {%- for Wellname in wells|unpack("Wellname") %}"{{Wellname}}" {% endfor %} |
| 38 | + Xvrs= {{ 3 * wells|length}} {# noqa: E301 #} |
| 39 | + {%- for Wellname in wells | unpack("Wellname") %} |
| 40 | + {{ Wellname }}PdhSP {{ Wellname }}PdhY {{ Wellname }}PdhHigh |
| 41 | + {% endfor %} |
| 42 | + |
| 43 | +// Filtering of SCG-source in for loop |
| 44 | +{% for Wellname in wells | selectattr(Linename, 'eq', 1) | unpack('Wellname') %} |
| 45 | + CalcPvr: {{ Linename }}Add{{Wellname}}Rate |
| 46 | + Text1= "Add swing well capacity up if it is active and not upper constrained" |
| 47 | + Text2= "" |
| 48 | + Alg= "setmeas({{ Linename }}Total, {{ Linename }}Total + {{ Wellname }}Rate)" |
| 49 | + |
| 50 | +{% endfor %} |
| 51 | + |
| 52 | +// Inline in calculations |
| 53 | + CalcPvr: {{ Flowline }}TotalCv |
| 54 | + Text1= "Total Cv for both topside chokes" |
| 55 | + Text2= "" |
| 56 | + Alg= "{% for Topline in toplines | selectattr('Flowline', 'eq', Flowline) | unpack('Topline') %}{{ Topline }}ChokeCv{% if not loop.last %} + {% endif %}{% endfor %}" |
| 57 | + |
| 58 | +// Using multiple parameters from one file |
| 59 | +{% for Wellname, StepSize in wells | unpack('Wellname', 'StepSize') %} |
| 60 | + CalcPvr: {{ Wellname }}PdhDbSize |
| 61 | + Text1= "" |
| 62 | + Text2= "" |
| 63 | + Alg= "max(0.2, 0.8*abs(modget({{ Wellname }}Pdh, {{ Wellname }}Zpc))*{{ StepSize }})" |
| 64 | + |
| 65 | +{% endfor %} |
0 commit comments