IdealPlanetary

model IdealPlanetary "Ideal planetary gear box"
    parameter Real ratio(start = 2) "Number of ring_teeth/sun_teeth (e.g., ratio=100/50)";
    Interfaces.Flange_a sun "Flange of sun shaft"
        annotation (Placement(transformation(extent = {
            {-110, -10}, 
            {-90, 10}})));
    Interfaces.Flange_a carrier "Flange of carrier shaft"
        annotation (Placement(transformation(extent = {
            {-110, 30}, 
            {-90, 50}})));
    Interfaces.Flange_b ring "Flange of ring shaft"
        annotation (Placement(transformation(extent = {
            {90, -10}, 
            {110, 10}})));
equation
    (1 + ratio) * carrier.phi = sun.phi + ratio * ring.phi;
    carrier.tau = -(1 + ratio) * sun.tau;
    ring.tau = ratio * sun.tau;

    annotation (
        Documentation(info = "<html>\n<p>\nThe IdealPlanetary gear box is an ideal gear without inertia,\nelasticity, damping or backlash consisting\nof an inner <strong>sun</strong> wheel, an outer <strong>ring</strong> wheel and a\n<strong>planet</strong> wheel located between sun and ring wheel. The bearing\nof the planet wheel shaft is fixed in the planet <strong>carrier</strong>.\nThe component can be connected to other elements at the\nsun, ring and/or carrier flanges. It is not possible to connect\nto the planet wheel. If inertia shall not be neglected,\nthe sun, ring and carrier inertias can be easily added by attaching\ninertias (= model Inertia) to the corresponding connectors.\nThe inertias of the planet wheels are always neglected.\n</p>\n<p>\nThe icon of the planetary gear signals that the sun and carrier\nflanges are on the left side and the ring flange is on the right side\nof the gear box. However, this component is generic and is valid\nindependently how the flanges are actually placed (e.g., sun wheel\nmay be placed on the right side instead on the left side in reality).\n</p>\n<p>\nThe ideal planetary gearbox is uniquely defined by the ratio\nof the number of ring teeth zr with respect to the number of\nsun teeth zs. For example, if there are 100 ring teeth and\n50 sun teeth then ratio = zr/zs = 2. The number of planet teeth\nzp has to fulfill the following relationship:\n</p>\n<pre>\n   <strong>zp := (zr - zs) / 2</strong>\n</pre>\n<p>\nTherefore, in the above example zp = 25 is required.\n</p>\n<p>\nAccording to the overall convention, the positive direction of all\nvectors, especially the absolute angular velocities and cut-torques\nin the flanges, are along the axis vector displayed in the icon.\n</p>\n\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    lineColor = {160, 160, 164},
                    fillColor = {160, 160, 164},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-50, 100}, 
                        {50, 105}}), 
                Rectangle(
                    lineColor = {160, 160, 164},
                    fillColor = {160, 160, 164},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-50, -105}, 
                        {50, -100}}), 
                Line(points = {
                    {-90, 40}, 
                    {-70, 40}}), 
                Line(points = {
                    {-80, 50}, 
                    {-60, 50}}), 
                Line(points = {
                    {-70, 50}, 
                    {-70, 40}}), 
                Line(points = {
                    {-80, 80}, 
                    {-59, 80}}), 
                Line(points = {
                    {-70, 100}, 
                    {-70, 80}}), 
                Text(
                    lineColor = {0, 0, 255},
                    extent = {
                        {-150, 110}, 
                        {150, 150}},
                    textString = "%name"), 
                Text(
                    extent = {
                        {-150, -150}, 
                        {150, -110}},
                    textString = "ratio=%ratio"), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {10, -100}, 
                        {50, 100}}), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-100, -10}, 
                        {-50, 10}}), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {50, -10}, 
                        {100, 10}}), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-80, 60}, 
                        {-50, 70}}), 
                Rectangle(
                    origin = {-30, 65},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-20, -19}, 
                        {20, 19}}), 
                Rectangle(
                    origin = {-30, 48},
                    fillColor = {153, 153, 153},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -2}, 
                        {20, 2}}), 
                Rectangle(
                    origin = {-30, 82},
                    fillColor = {204, 204, 204},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -2}, 
                        {20, 2}}), 
                Rectangle(
                    origin = {-30, 59},
                    fillColor = {204, 204, 204},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -4}, 
                        {20, 4}}), 
                Rectangle(
                    origin = {-30, 73},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -3}, 
                        {20, 3}}), 
                Rectangle(
                    origin = {-30, -1},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-20, -35}, 
                        {20, 35}}), 
                Rectangle(
                    origin = {-30, 32},
                    fillColor = {153, 153, 153},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -2}, 
                        {20, 2}}), 
                Rectangle(
                    origin = {-30, 23},
                    fillColor = {204, 204, 204},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -3}, 
                        {20, 3}}), 
                Rectangle(
                    origin = {-30, -10},
                    fillColor = {204, 204, 204},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -4}, 
                        {20, 4}}), 
                Rectangle(
                    origin = {-30, -34},
                    fillColor = {102, 102, 102},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -2}, 
                        {20, 2}}), 
                Rectangle(
                    origin = {-30, -25},
                    fillColor = {153, 153, 153},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -3}, 
                        {20, 3}}), 
                Rectangle(
                    origin = {-30, 8},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -4}, 
                        {20, 4}}), 
                Rectangle(
                    origin = {-30, 65},
                    fillColor = {192, 192, 192},
                    extent = {
                        {-20, -19}, 
                        {20, 19}}), 
                Rectangle(
                    origin = {-30, -1},
                    fillColor = {255, 255, 255},
                    extent = {
                        {-20, -35}, 
                        {20, 35}}), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {255, 255, 255},
                    extent = {
                        {10, -100}, 
                        {50, 100}})}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-100, -10}, 
                        {-50, 10}}), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {50, -10}, 
                        {100, 10}}), 
                Rectangle(
                    lineColor = {160, 160, 164},
                    fillColor = {160, 160, 164},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-50, 100}, 
                        {50, 105}}), 
                Rectangle(
                    lineColor = {160, 160, 164},
                    fillColor = {160, 160, 164},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-50, -105}, 
                        {50, -100}}), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-80, 60}, 
                        {-50, 70}}), 
                Line(points = {
                    {-90, 40}, 
                    {-70, 40}}), 
                Line(points = {
                    {-80, 50}, 
                    {-60, 50}}), 
                Line(points = {
                    {-70, 50}, 
                    {-70, 40}}), 
                Line(points = {
                    {-80, 80}, 
                    {-59, 80}}), 
                Line(points = {
                    {-70, 90}, 
                    {-70, 80}}), 
                Line(
                    points = {
                        {-26, -42}, 
                        {-32, -2}},
                    color = {0, 0, 255},
                    pattern = LinePattern.Dot), 
                Text(
                    lineColor = {0, 0, 255},
                    extent = {
                        {58, -78}, 
                        {98, -66}},
                    textString = "ring gear"), 
                Text(
                    lineColor = {0, 0, 255},
                    extent = {
                        {-112, 87}, 
                        {-56, 111}},
                    textString = "planet carrier "), 
                Text(
                    lineColor = {0, 0, 255},
                    extent = {
                        {-47, -56}, 
                        {-3, -42}},
                    textString = "sun gear"), 
                Polygon(
                    lineColor = {128, 128, 128},
                    fillColor = {128, 128, 128},
                    fillPattern = FillPattern.Solid,
                    points = {
                        {58, 130}, 
                        {28, 140}, 
                        {28, 120}, 
                        {58, 130}}), 
                Line(points = {
                    {-52, 130}, 
                    {28, 130}}), 
                Line(
                    points = {
                        {-92, 93}, 
                        {-70, 80}},
                    color = {0, 0, 255},
                    pattern = LinePattern.Dot), 
                Polygon(
                    lineColor = {128, 128, 128},
                    fillColor = {128, 128, 128},
                    fillPattern = FillPattern.Solid,
                    points = {
                        {-7, -86}, 
                        {-27, -81}, 
                        {-27, -91}, 
                        {-7, -86}}), 
                Line(
                    points = {
                        {-97, -86}, 
                        {-26, -86}},
                    color = {128, 128, 128}), 
                Text(
                    lineColor = {128, 128, 128},
                    extent = {
                        {-96, -84}, 
                        {-28, -71}},
                    textString = "rotation axis"), 
                Rectangle(
                    origin = {-30, 65},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-20, -19}, 
                        {20, 19}}), 
                Rectangle(
                    origin = {-30, 48},
                    fillColor = {153, 153, 153},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -2}, 
                        {20, 2}}), 
                Rectangle(
                    origin = {-30, 82},
                    fillColor = {204, 204, 204},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -2}, 
                        {20, 2}}), 
                Rectangle(
                    origin = {-30, 59},
                    fillColor = {204, 204, 204},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -4}, 
                        {20, 4}}), 
                Rectangle(
                    origin = {-30, 73},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -3}, 
                        {20, 3}}), 
                Rectangle(
                    origin = {-30, 65},
                    fillColor = {192, 192, 192},
                    extent = {
                        {-20, -19}, 
                        {20, 19}}), 
                Rectangle(
                    origin = {-30, -1},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-20, -35}, 
                        {20, 35}}), 
                Rectangle(
                    origin = {-30, 32},
                    fillColor = {153, 153, 153},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -2}, 
                        {20, 2}}), 
                Rectangle(
                    origin = {-30, 23},
                    fillColor = {204, 204, 204},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -3}, 
                        {20, 3}}), 
                Rectangle(
                    origin = {-30, -10},
                    fillColor = {204, 204, 204},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -4}, 
                        {20, 4}}), 
                Rectangle(
                    origin = {-30, -34},
                    fillColor = {102, 102, 102},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -2}, 
                        {20, 2}}), 
                Rectangle(
                    origin = {-30, -25},
                    fillColor = {153, 153, 153},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -3}, 
                        {20, 3}}), 
                Rectangle(
                    origin = {-30, 8},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-20, -4}, 
                        {20, 4}}), 
                Rectangle(
                    origin = {-30, -1},
                    fillColor = {255, 255, 255},
                    extent = {
                        {-20, -35}, 
                        {20, 35}}), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {10, -100}, 
                        {50, 100}}), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {255, 255, 255},
                    extent = {
                        {10, -100}, 
                        {50, 100}}), 
                Line(
                    points = {
                        {36, -26}, 
                        {64, -60}},
                    color = {0, 0, 255},
                    pattern = LinePattern.Dot)}));
end IdealPlanetary;