LIBRARY
Continuous.Tests.PID
Combined test harness for the PID controller.
Four PID configurations are exercised in one component, each closing a loop around its own Plant but driven by the same shared unit-step setpoint (signal):
pidFull— full PID (with_I = true,with_D = true)pidPI— PI (with_D = false)pidPD— PD (with_I = false)pidP— P only (with_I = false,with_D = false)
The four closed-loop responses (plant*.y) and controller outputs (pid*.y) are compared in a single test case rather than in separate components.
Usage
BlockComponents.Continuous.Tests.PID()
Behavior
Source
dyad
"""
Combined test harness for the PID controller.
Four `PID` configurations are exercised in one component, each closing a loop
around its own `Plant` but driven by the **same** shared unit-step setpoint
(`signal`):
- `pidFull` — full PID (`with_I = true`, `with_D = true`)
- `pidPI` — PI (`with_D = false`)
- `pidPD` — PD (`with_I = false`)
- `pidP` — P only (`with_I = false`, `with_D = false`)
The four closed-loop responses (`plant*.y`) and controller outputs (`pid*.y`) are
compared in a single test case rather than in separate components.
"""
test component PID
"Unit-step setpoint shared by all four controllers"
signal = BlockComponents.Sources.Step(height = 1) {"Dyad": {"placement": {"diagram": {"x1": 0, "x2": 100, "y1": 500, "y2": 600}}}}
"Full PID controller"
pidFull = BlockComponents.Continuous.PID(Td = 0.1, Ti = 0.5, wp = 1, wd = 0, Nd = 10) {
"Dyad": {"placement": {"diagram": {"x1": 400, "x2": 500, "y1": 770, "y2": 870}}}
}
"Plant controlled by the full PID"
plantFull = BlockComponents.Continuous.Plant() {
"Dyad": {"placement": {"diagram": {"x1": 580, "x2": 680, "y1": 770, "y2": 870}}}
}
"PI controller (derivative part structurally removed)"
pidPI = BlockComponents.Continuous.PID(with_D = false, Ti = 0.5, wp = 1) {
"Dyad": {"placement": {"diagram": {"x1": 400, "x2": 500, "y1": 540, "y2": 640}}}
}
"Plant controlled by the PI controller"
plantPI = BlockComponents.Continuous.Plant() {
"Dyad": {"placement": {"diagram": {"x1": 570, "x2": 670, "y1": 540, "y2": 640}}}
}
"PD controller (integral part structurally removed)"
pidPD = BlockComponents.Continuous.PID(with_I = false, Td = 0.1, wp = 1, wd = 0, Nd = 10) {
"Dyad": {"placement": {"diagram": {"x1": 400, "x2": 500, "y1": 90, "y2": 190}}}
}
"Plant controlled by the PD controller"
plantPD = BlockComponents.Continuous.Plant() {
"Dyad": {"placement": {"diagram": {"x1": 570, "x2": 670, "y1": 90, "y2": 190}}}
}
"P controller (integral and derivative parts structurally removed)"
pidP = BlockComponents.Continuous.PID(with_I = false, with_D = false, wp = 1) {
"Dyad": {"placement": {"diagram": {"x1": 400, "x2": 500, "y1": 300, "y2": 400}}}
}
"Plant controlled by the P controller"
plantP = BlockComponents.Continuous.Plant() {
"Dyad": {"placement": {"diagram": {"x1": 570, "x2": 670, "y1": 300, "y2": 400}}}
}
relations
initial plantFull.x1 = 0
initial plantFull.y = 0
initial plantPI.x1 = 0
initial plantPI.y = 0
initial plantPD.x1 = 0
initial plantPD.y = 0
initial plantP.x1 = 0
initial plantP.y = 0
connect(plantFull.y, pidFull.u_m) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 720, "y": 820},
{"x": 720, "y": 900},
{"x": 370, "y": 900},
{"x": 370, "y": 843}
],
"E": 2
}
]
}
}
connect(pidFull.y, plantFull.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(plantPI.y, pidPI.u_m) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 720, "y": 590},
{"x": 720, "y": 670},
{"x": 360, "y": 670},
{"x": 360, "y": 613}
],
"E": 2
}
]
}
}
connect(pidPI.y, plantPI.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(plantPD.y, pidPD.u_m) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 720, "y": 140},
{"x": 720, "y": 220},
{"x": 365, "y": 220},
{"x": 365, "y": 163}
],
"E": 2
}
]
}
}
connect(pidPD.y, plantPD.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(plantP.y, pidP.u_m) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 730, "y": 350},
{"x": 730, "y": 430},
{"x": 370, "y": 430},
{"x": 370, "y": 373}
],
"E": 2
}
]
}
}
connect(pidP.y, plantP.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(pidPI.u_s, signal.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 130, "y": 567}, {"x": 130, "y": 550}], "E": 2}]}
}
connect(pidFull.u_s, signal.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 130, "y": 797}, {"x": 130, "y": 550}], "E": 2}]}
}
connect(pidP.u_s, signal.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 130, "y": 327}, {"x": 130, "y": 550}], "E": 2}]}
}
connect(pidPD.u_s, signal.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 130, "y": 117}, {"x": 130, "y": 550}], "E": 2}]}
}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {
"case1": {
"stop": 10,
"atol": {
"plantFull.y": 0.0001,
"plantPI.y": 0.0001,
"plantPD.y": 0.0001,
"plantP.y": 0.0001,
"pidFull.y": 0.0001,
"pidPI.y": 0.0001,
"pidPD.y": 0.0001,
"pidP.y": 0.0001
},
"expect": {
"signals": [
"plantFull.y",
"plantPI.y",
"plantPD.y",
"plantP.y",
"pidFull.y",
"pidPI.y",
"pidPD.y",
"pidP.y"
]
}
}
}
}
}
endFlattened Source
dyad
"""
Combined test harness for the PID controller.
Four `PID` configurations are exercised in one component, each closing a loop
around its own `Plant` but driven by the **same** shared unit-step setpoint
(`signal`):
- `pidFull` — full PID (`with_I = true`, `with_D = true`)
- `pidPI` — PI (`with_D = false`)
- `pidPD` — PD (`with_I = false`)
- `pidP` — P only (`with_I = false`, `with_D = false`)
The four closed-loop responses (`plant*.y`) and controller outputs (`pid*.y`) are
compared in a single test case rather than in separate components.
"""
test component PID
"Unit-step setpoint shared by all four controllers"
signal = BlockComponents.Sources.Step(height = 1) {"Dyad": {"placement": {"diagram": {"x1": 0, "x2": 100, "y1": 500, "y2": 600}}}}
"Full PID controller"
pidFull = BlockComponents.Continuous.PID(Td = 0.1, Ti = 0.5, wp = 1, wd = 0, Nd = 10) {
"Dyad": {"placement": {"diagram": {"x1": 400, "x2": 500, "y1": 770, "y2": 870}}}
}
"Plant controlled by the full PID"
plantFull = BlockComponents.Continuous.Plant() {
"Dyad": {"placement": {"diagram": {"x1": 580, "x2": 680, "y1": 770, "y2": 870}}}
}
"PI controller (derivative part structurally removed)"
pidPI = BlockComponents.Continuous.PID(with_D = false, Ti = 0.5, wp = 1) {
"Dyad": {"placement": {"diagram": {"x1": 400, "x2": 500, "y1": 540, "y2": 640}}}
}
"Plant controlled by the PI controller"
plantPI = BlockComponents.Continuous.Plant() {
"Dyad": {"placement": {"diagram": {"x1": 570, "x2": 670, "y1": 540, "y2": 640}}}
}
"PD controller (integral part structurally removed)"
pidPD = BlockComponents.Continuous.PID(with_I = false, Td = 0.1, wp = 1, wd = 0, Nd = 10) {
"Dyad": {"placement": {"diagram": {"x1": 400, "x2": 500, "y1": 90, "y2": 190}}}
}
"Plant controlled by the PD controller"
plantPD = BlockComponents.Continuous.Plant() {
"Dyad": {"placement": {"diagram": {"x1": 570, "x2": 670, "y1": 90, "y2": 190}}}
}
"P controller (integral and derivative parts structurally removed)"
pidP = BlockComponents.Continuous.PID(with_I = false, with_D = false, wp = 1) {
"Dyad": {"placement": {"diagram": {"x1": 400, "x2": 500, "y1": 300, "y2": 400}}}
}
"Plant controlled by the P controller"
plantP = BlockComponents.Continuous.Plant() {
"Dyad": {"placement": {"diagram": {"x1": 570, "x2": 670, "y1": 300, "y2": 400}}}
}
relations
initial plantFull.x1 = 0
initial plantFull.y = 0
initial plantPI.x1 = 0
initial plantPI.y = 0
initial plantPD.x1 = 0
initial plantPD.y = 0
initial plantP.x1 = 0
initial plantP.y = 0
connect(plantFull.y, pidFull.u_m) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 720, "y": 820},
{"x": 720, "y": 900},
{"x": 370, "y": 900},
{"x": 370, "y": 843}
],
"E": 2
}
]
}
}
connect(pidFull.y, plantFull.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(plantPI.y, pidPI.u_m) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 720, "y": 590},
{"x": 720, "y": 670},
{"x": 360, "y": 670},
{"x": 360, "y": 613}
],
"E": 2
}
]
}
}
connect(pidPI.y, plantPI.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(plantPD.y, pidPD.u_m) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 720, "y": 140},
{"x": 720, "y": 220},
{"x": 365, "y": 220},
{"x": 365, "y": 163}
],
"E": 2
}
]
}
}
connect(pidPD.y, plantPD.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(plantP.y, pidP.u_m) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 730, "y": 350},
{"x": 730, "y": 430},
{"x": 370, "y": 430},
{"x": 370, "y": 373}
],
"E": 2
}
]
}
}
connect(pidP.y, plantP.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
connect(pidPI.u_s, signal.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 130, "y": 567}, {"x": 130, "y": 550}], "E": 2}]}
}
connect(pidFull.u_s, signal.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 130, "y": 797}, {"x": 130, "y": 550}], "E": 2}]}
}
connect(pidP.u_s, signal.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 130, "y": 327}, {"x": 130, "y": 550}], "E": 2}]}
}
connect(pidPD.u_s, signal.y) {
"Dyad": {"edges": [{"S": 1, "M": [{"x": 130, "y": 117}, {"x": 130, "y": 550}], "E": 2}]}
}
metadata {
"Dyad": {
"icons": {"default": "dyad://BlockComponents/Example.svg"},
"tests": {
"case1": {
"stop": 10,
"atol": {
"plantFull.y": 0.0001,
"plantPI.y": 0.0001,
"plantPD.y": 0.0001,
"plantP.y": 0.0001,
"pidFull.y": 0.0001,
"pidPI.y": 0.0001,
"pidPD.y": 0.0001,
"pidP.y": 0.0001
},
"expect": {
"signals": [
"plantFull.y",
"plantPI.y",
"plantPD.y",
"plantP.y",
"pidFull.y",
"pidPI.y",
"pidPD.y",
"pidP.y"
]
}
}
}
}
}
endTest Cases
Test Case case1
julia
pltjulia
pltjulia
pltjulia
pltjulia
pltjulia
pltjulia
pltjulia
pltRelated
Examples
Experiments
Analyses
Tests