You definitely need the "nodes" section if you want your custom valve to connect to one of the pre-existing domains. For example, for the hydraulic domain:
nodes
A = foundation.hydraulic.hydraulic; % A:left
B = foundation.hydraulic.hydraulic; % B:right
end
In addition, you do not need to use two variables named "p1" and "p2" if you are using hydraulic nodes. You simply define one variable "p" which can then be defined in the "equations" section using the nodes you set up above.
p == A.p - B.p;
Finally, "branches" will define the sign convention of the other variable -- which is flow rate. In other words, is flow positive from A to B or from B to A?
branches
q : A.q -> B.q;
end
I think you should look at the existing .ssc source code for a similar block. For instance, you can double-click a Constant Area Hydraulic Orifice block and use the "Source code" hyperlink to see its implementation. Then, right-click the "foundation.hydraulic.branch" to look into some more of the code. The orifice block "inherits" from that branch template and fills in the remaining details to complete the orifice model and dialog/parameters.
- Sebastian