I'm trying to simulate a simple case. One sweptVolume is connected to another one. Flange.b to flange.b like that:

When the pressure in the OilChamber is rising, the volume expands, and the piston moves out. (So far, all good and logical).
The GasChamber volume should decrease, and the pressure should rise (we have a compression scenario). The Gas Chamber has no hydraulic output. It is Closed.
However, on the plot, I can see that the Gas chamber piston is moving out, the pressure is decreasing, and the volume is expanding.
I thought that If two hydraulic cylinders are connected, the first expands and the second collapses (this is what you usually expect in Matlab).
How can I inverse the second sweptVolume?
Here is my code:
model Jack1
inner Modelica.Fluid.System system(energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial) annotation(
Placement(visible = true, transformation(origin = {0, 56}, extent = {{60, -96}, {80, -76}}, rotation = 0)));
Modelica.Mechanics.Translational.Sources.Force force annotation(
Placement(visible = true, transformation(origin = {-30, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Sources.Ramp ramp(duration = 6, height = -250, startTime = 1) annotation(
Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Machines.SweptVolume OilChamber(redeclare package Medium = Modelica.Media.Water.StandardWater, clearance = 0.00105, flange(s(start = 0.1)), nPorts = 1, pistonCrossArea = 0.0019625, portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.014)}) annotation(
Placement(visible = true, transformation(origin = {0, 8}, extent = {{10, -10}, {-10, 10}}, rotation = 180)));
Modelica.Fluid.Machines.SweptVolume Jack(redeclare package Medium = Modelica.Media.Water.StandardWater, clearance = 0.00105, flange(s(start = 0.1)), nPorts = 1, pistonCrossArea = 0.0019625, portsData = {Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter = 0.01)}) annotation(
Placement(visible = true, transformation(origin = {0, 48}, extent = {{10, 10}, {-10, -10}}, rotation = -180)));
Modelica.Fluid.Machines.SweptVolume GasChamber(redeclare package Medium = Modelica.Media.IdealGases.SingleGases.N2, clearance = 0.00105, flange(s(start = 0.1)), nPorts = 0, pistonCrossArea = 0.0019625) annotation(
Placement(visible = true, transformation(origin = {0, -30}, extent = {{10, 10}, {-10, -10}}, rotation = 180)));
equation
connect(ramp.y, force.f) annotation(
Line(points = {{-59, 70}, {-43, 70}}, color = {0, 0, 127}));
connect(force.flange, Jack.flange) annotation(
Line(points = {{-20, 70}, {0, 70}, {0, 58}}, color = {0, 127, 0}));
connect(OilChamber.ports[1], Jack.ports[1]) annotation(
Line(points = {{0, 18}, {0, 38}}, color = {0, 127, 255}));
connect(OilChamber.flange, GasChamber.flange) annotation(
Line(points = {{0, -2}, {0, -20}}, color = {0, 127, 0}));
annotation(
uses(Modelica(version = "4.0.0")),
Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}})));
end Jack1;
The underlying problem is that SweptVolume should have two flanges (for the two sides) - not just one. It seems kind of possible to fix it by having an adapter that switches the orientation for the flanges, but I cannot fully get it to work.
However, it may be a start and for reversing the flange-orientation:
And then use it in the updated model:
But unfortunately the simulation stops after about 8s. There might be sign-errors, or some other logic error - but at least it is a starting point.