-
Notifications
You must be signed in to change notification settings - Fork 1
Power connectors are not locally balanced because they only contain one flow variable : W #99
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
With reference to the Modelica Spec. 9.3.1: The only way to satisfy this requirement in MML3 is to add a "dummy" effort variable in both the power Inlet and Outlet connectors (e.g., Looking at MML3 I saw that the all the connection-set that involve power connectors contain one and only one Inlet connector, so the dummy variable could be written by the components that have a power input connector (e.g. the Generator). This can be done for example by adding a bounding equation where the connector is instantiated:
|
Thanks for the clarification. Since the |
I defined a |
The idea is that only the component that have an "inlet" connector should also have the binding equation, so in this case only the "sink" component. |
This should be not necessary, the point is that only the |
Consider also that the model should be balanced itself (not only their connectors). For example the |
Yes I had done this mistake before but I corrected it, it should be only on inlets now, excepted for the source. |
This is because now the connector is balanced but not the model (see also the comment before). |
We had a meeting today with @pepmts, @casella and @AndreaBartolini to discuss the issue. After some internal discussion, we came up with an assessment of the current status and a proposal, that will be posted here ASAP. We should then call another meeting with @pepmts to ensure he understands it fully and agrees with it, or possibly to change it according to his further input. |
Part 1: Connector definitions The first issue is that the connector Inlet
import MetroscopeModelingLibrary.Units;
flow Units.PositivePower W;
end Inlet;
connector Outlet
import MetroscopeModelingLibrary.Units;
flow Units.NegativePower W;
end Outlet; For truly physical models (e.g. electrical or mechanical) one would have also a physical effort variable. For example, in mechanically connected components, this could be the angle or angular velocity of the mechanical flanges, which are then connected (-> welded) together to enable the power exchange. For electrically connected components, this could be the voltage of the electrical ports, which are then connected (-> plugged) together to enable the power exchange. These models would then in general contain an equation establishing some relationship between the power and the velocity/voltage. Something akin to a voltage-current relationship in DC electrical components. This is for example useful when modelling turbojet engines, where you have compressors, turbines, and fans on the same shaft, whose behaviour strongly depends on speed. What you need here, however, is a lot more abstract, i.e., you need to model transfer of power, regardless of the concrete physical phenomenon behind it. Furthermore, your models do not need generic flow-effort relationships, but fall only in two categories
In some sense, even though you use completely general flow-effort connectors, your components are akin to either ideal voltage sources or ideal current sources. No resistors, and no real generators with internal impedance. Therefore, you can define connectors with a dummy effort variables. connector PowerWriter "Writes the power flow based on the inner working of the component"
import MetroscopeModelingLibrary.Units;
flow Units.Power W;
Units.NotUsed dummy "dummy effort variable to balance the connector, value not used";
end PowerWriter;
connector PowerReader "Reads the power flow coming from the other components that write it"
import MetroscopeModelingLibrary.Units;
flow Units.Power W;
Units.NotUsed dummy "dummy effort variable to balance the connector, value not used";
end PowerReader; Components that generate or consume a certain power regardless of the other connected components will set the flow variable (power) on the connector; note that the actual direction of power flow (entering or leaving) is irrelevant, what matters it what this power flow depends upon. Components that instead take in (or out) whatever power is generated (or consumed) by the other connected components will set the dummy variable, to a dummy value of zero. Notice that you must have one and only one such component in the same connection set; if you have none, the power generated by the components of the other type would have nowhere to go. If you have more than one, the system of equations will be balanced, but over- and under-determined at the same time (thus singular) because you are setting the dummy variable many times, and there is no way to determine how the power flow is split among them. Some remarks, compared to the current tentative implementation in the fix-power-connector-balance branch:
|
Part 2: Component definitions When tackling component definitions, we consider the basic design decision of Metroscope, regarding the change of causality to solve inverse problem: each component has certain connector input variables, which are the "default" prescribed variables. The default structure of the component is thus obtained when all the connectors are connected: the ones carrying the fluid, the power connectors, and the input connectors (e.g. the rotational speed in pumps). It is then possible to change the causality and solve inverse problems by not connecting those input connectors, and by adding other suitable equations to the system model instead. From this point of view, the turbine and the pump are similar. The turbine model implicitly assumes a fixed speed, corresponding to 50 Hz synchronous behaviour. The pump model instead has a rotational speed input, so by default it has a fixed speed as well. If one connects the fluid inlet and outlet ports, e.g. to two fixed-pressure and enthalpy components, and also connects the rotational speed input in the case of the pump, then the behaviour of the machine is completely determined, in terms of flow rate and power production/consumption. The only difference is that the turbine will have a negative flow variable on the connector, the pump will have a positive one, but in both cases the power flow it will be determined by the machine, not by some other component connected to it. From this point of view, note that the current Pump model in the Both turbine and pump models will contain an equation setting the On the other side, we have the Generator model. This one instead will have a The handling of the connection between turbines and electrical generator will be exactly the same as in the currently developed If instead you want to explicitly prescribe the power input to the pump, and get the rotational speed as a consequence, then you need to enable the inverse computation configuration: disconnect the rotational speed input connector of the pump, so that this becomes a free variable, then add a system equation such as It is also possible to define a In this way, connectors are balanced, individual models are balanced, and the design of the library is totally symmetric, consistent, and easy to document and explain. Once more, one has to be careful to always have one and only one full power connector in each connection set involving power connectors, otherwise one would get some singular system diagnostics, either at compile time or at runtime. |
Okay ! That was indeed a long story ! It seems to me that this solution works most of the time, but we sometimes have a connection from the turbine power connector to the pump power connector (for turbopump) but in that case we have no Maybe I misunderstood some part, could you propose an implementation if I am wrong ? |
I think a solution can be found, but I need to understand exactly what you want to model in that case: are the turbine and the pump free to change their rotational speed, until they reach some kind of equilibrium? In that case, you need some way to get the shaft speed into the turbine model, this is really not possible with such abstract power connectors, because they don't convey that information. You would need physical mechanical connectors to do that. |
There are two possible causalities in such models :
Can we still use this |
@pepmts, this is still not clear to me. Let me get there in steps. Case 1: pump with electric drive (this case is already covered by our proposal) Assume you have a pump actuated by a variable speed drive. In forward mode, the input rotational speed is given. This corresponds to operating the variable speed drive with a fixed speed set point. In this case, obviously, the pump power will be an output of the calculation, and you may represent that explicitly as coming from a PowerSource model,as we discussed already. In reverse mode, the pump speed is used to control something, a temperature, a pressure, a flow rate, the absorbed power, whatever. In this case, you leave the rotational speed unconnected, and then add one more equation to specify what you want to control. This corresponds implicitly to representing a control system that keeps what you want at its set point, by acting on the rotational speed, with a cascaded control strategy. Obviously, if you fix the controlled output to some set point, the rotational speed is completely determined by that, so it becomes a system output. Case 2: turbo-pump (still unclear) Assume now the pump is actuated by a turbine which is explicitly modelled in the system's flow diagram. As in the previous case, the actuator will need to have one degree of freedom to control it. For the electrically actuated pump, it was the rotational speed set point of the variable speed drive. I'm not sure what it is in the case of the turbine (this is a question for you). It could be, e.g. some throttling valve opening. So, this turbine model in forward mode will compute its power output, that will also depend on this extra degree of freedom (e.g. throttling valve). I can come up with a modular solution that deals with the dummy variable, but before we delve into actual mathematical modelling, we first need to understand how the turbine power is actually controlled in turbo-pump settings. I guess it's through some throttling valve, but maybe it's done differently. @pepmts can you please comment on that? |
(I did not forgot this question, I am currently diggig a bit) |
I think the final answer of the turbopump causality is "it depends". Usually the pump would compute itself the needed power, if we lack some sensors we would add hypothesis, but the power would still be computed by the pump I think. The "it depend" case is because we could have more sensors on the turbine side than on the pump side, leaving less degrees of freedom on the turbine and thus imposing more degrees of freedom, such as the pump's power. @valentindrou if you want to comment this last part ? |
In the end, this "it depends" case pushes me to think that the previous solution proposed by @AndreaBartolini that I implemented in #278 is the best one so far, but I am not sure I understood everything yet on this case |
It seems to me that, at the end, we need to manage the case in that a component (like pump or turbine) can have a power connector that works as either "reader" or "writer" depending on the overall model, but the reader/writer causality doesn't change during the simulation of the overall model (i.e, it is structurally defined in the overall model). |
Yes ! |
Causality never changes during the simulation |
I'm sorry, but I'm afraid there is a misunderstanding here. The question is not how you model the turbopump from a mathematical point of view (hence who computes what). The question is, how is it operated in real life. How is the turbine power actually controlled in a turbo-pump configuration? Is there some turbine throttling valve operated by a controller? |
Yes there is a throttle valve, though we do not usually have its opening. |
That is not necessary. My point is that, conceptually, the throttling valve opening will be used to control something. The solution to deal with the turbopump, without resorting to complicated solutions (e.g. conditional connectors) could then be the following, which uses the balanced components we already proposed
That's it. Providing no input for the pump rotational speed is easy: just leave the rotational speed input unconnected and do not provide any equation for it. Providing no input for the throttling valve opening is a bit trickier, because that input has a default binding, and there is no way to remove it when instantiating it. I guess the easiest way to deal with that is to declare one extra free variable in the system and then pass its value as a binding equation to the turbine throttling valve opening. This will replace the default binding with a variable that has no equation, so it will add the required extra degree of freedom, to be matched by the equation prescribing the value of some controlled variable to its set point. Is this OK? |
I am sorry but from a user experience point of view this seems super complicated
As you said in the previous meeting, I would be a bit mad with my colleagues if I had to do this is because it is an unnecessary and counterintuitive modification, and it has no physical meaning. To me, having to add a power source, then set its power to 0, all this just to handle the dummy variable is really too complicated. To my mind, it is still better to do as in #278 :
Maybe @valentindrou you would have a different point of view ? |
@pepmts, I am still a bit confused about what you want to do with the Pump model. In #278 you set the dummy (or not_used) variable of the power port in the pump model. This means that the power port in the pump is a "power reader", as in the case of the generators. But then, you showed us example models where you connect the pump to a generator. In this case you'd have two power readers, both trying to set the dummy variable. This of course cannot work. My point is, you can't have it both ways. Either the pump port is a power reader, or it is a power writer. From my perspective, it is more natural to make it a writer, since the mathematical structure of a turbine model (which we all agree should compute the generated power by default) and the mathematical structure of a pump model are exactly the same. The only difference is the sign conventions. Do I miss something? Please also note that these power ports are not really physical connectors. They pretend to, but they aren't. A real physical connector would carry two coupled flow and effort variables, whose product is related to power transfer. That way, they could be connected in all the ways that make physical sense. These power ports are actually generalized inputs and output connectors, the generalization being that you can have multiple outputs which all get summed into a single input. Therefore, library users must be aware of this fact, lest they run into trouble. |
This should not happen, maybe thare was a misunderstanding, but this cannot happen since power is not produced by the generator nor by the pump. This connection set would make no sense, I am sorry if I wrote it some where, it is not something we encounter. What I mean in #278 is that since for every power connection set, there is one and only one connector expecting a power with a negative sign (and this sign cannot change, no matter the causality), we can use this connector expecting a negative sign to set the dummy variable. I agree these connectors don't really have a physical meaning, we only try to find a way to make them balanced with the dummy variable.
Agreed, this is something that we must document, but it is much easier to understand than the causality approach, I think. |
I'm afraid I am not clear above, so I'll add one point :
I don't think it makes sense to interprete it like that. The causality approach and the sign one (in #278) are not equivalent : in the sign convention, a component that sets It is just two different ways of handling the I hope it makes things clearer but I am not sure ;) maybe another meeting would save us time ;) |
I can't follow you here. If the pumps are expected to have a power port, you have to connect them to something. Otherwise, the unconnected port will cause a default connection equation I any case, I am quite sure I saw such pump-generator connections in some test cases. @AndreaBartolini do you remember where? |
Of course it does. Physical ports have pairs of flow-effort variables. The idea is that the component internally enforces some relationship among them (e.g. V = R*I for a resistor), and then the connected component provides another relationship (e.g V = V0 or I = I0 or V = V0 - RI), closing the overall system model. If the pump model sets the dummy variable, the other power variable is free, and needs to be set by the other connected components. Hence, the pump model will read whatever power value the other connected component(s) will set. That's how balanced connectors work.
I'm not sure what you mean exactly by the "sign approach", but the concept of balanced connectors in Modelica is based on equations-variables count. It has nothing to do with the actual values of variables. In some cases causality and sign may actually coincide, and this may help the end user, but at the end of the day what matters for balancedness is the mathematical structure, not the actual values
See above. |
@casella I don't think we link pumps to generators, but we do link them to a turbine, for the turbopump discussed above, otherwise we only link them to power sources |
Do you mean that if the pump sets the |
I mean the one implemented in #278, and currently in MML, where power connectors are named |
I completely agree
I agree too. But with the idea of "the connector that only accepts negative power sets the |
Generators and power sources are the same story. They set the dummy variable and accept/read (i.e. supply, from a physical point of view) whatever sum of power flows in their port from the other components that determine them. Once again, the sign of the power flows is irrelevant. |
Of course not. That would be an unbalanced component. Balanced components can only set one condition for each pair of flow/effort variables. |
Sure. This means that for pump-power source connections, since the power source sets dummy, the pump cannot set it as well. The pump is a "power writer" (same as the turbine, with opposite sign), the source a power reader (same as generator, with opposite sign). Hope this clarifies the issue 😅 |
Okay ! We've discussed this with @valentindrou and I think we can come up with a solution !
Concerning your causality approach of power connectors, I think we would still have problems wor what is happening after the generator (usually, a power sensor and a power sink), because the power sink is necessarily a Dropping the pump power connector will probably simplify this conversation a lot |
Interesting, I didn't know that ! |
This is one option. However, a really satisfactory modular design shouldn't force you to do this tricks. I still wonder if there isn't some other way to deal with these power connectors, that is elegant, easy to use, easy to understand, and easy to code. The current solution is not ideal from this point of view.
I'm not sure I understand the role of the PowerSensor. Why doesn'it simply have a power output, but rather a C_out power port? Is it because you still want to be able to sum many of them and get the total computed in a further PowerReader? |
@pepmts, as I understand once you remove the power connector from the pump, what I proposed and what you tried in #278 are the same thing. Do I miss something? |
Modelica Specification, Section 9.3.1:
Section 2 of this paper clearly motivates why it has to be so. When checking balanced components, the rules in Section 4.7 state that for each flow variable in top-level connectors you must count one extra equation. Combined with the rule of Section 9.3.1, this means that any physical model has one free degree of freedom for each pair of effort/flow variables in top connectors. This is the only way you can guarantee to always get balanced models no matter how you connect them. When you connect two such balanced models you have two degrees of freedom, which match one equation for the effort variables being equal and one for the flow variables to sum to zero. When you connect three of them, you have three degrees of freedom that match effort1 = effort2, effort2 = effort3, flow1 + flow2 + flow3 = 0. And so on and so forth. |
Almost, there is the issue with power sensor, which currently has two connectors |
The power sensor is in the line because we usually do that for all sensors, to avoid some errors, but since power sensor are always put after the generator, yes it could be relevant to use only one PowerReader output |
Connectors should have the same number of flow and other normal variables, how should we handle this in MML3 ?
The text was updated successfully, but these errors were encountered: