source: src/main/java/agents/anac/y2015/agentBuyogV2/flanagan/control/Compensator.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 5.8 KB
Line 
1/* Class Compensator
2*
3* This class contains the constructor to create an instance of
4* a generalised compensator,
5* K(a + s)/(b + s)
6* and the methods needed to use this process in simulation
7* of control loops.
8*
9* This class is a subclass of the superclass BlackBox.
10*
11* Author: Michael Thomas Flanagan.
12*
13* Created: 14 May 2005
14* Updates: 13 April 2006, 1 July 2006, 6 April 2008, 2 December 2008, 2-7 November 2009
15*
16*
17* DOCUMENTATION:
18* See Michael T Flanagan's JAVA library on-line web page:
19* http://www.ee.ucl.ac.uk/~mflanaga/java/Compensator.html
20* http://www.ee.ucl.ac.uk/~mflanaga/java/
21*
22* Copyright (c) 2002 - 2009 Michael Thomas Flanagan
23*
24* PERMISSION TO COPY:
25*
26* Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is granted, without fee,
27* provided that an acknowledgement to the author, Dr Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies
28* and associated documentation or publications.
29*
30* Redistributions of the source code of this source code, or parts of the source codes, must retain the above copyright notice, this list of conditions
31* and the following disclaimer and requires written permission from the Michael Thomas Flanagan:
32*
33* Redistribution in binary form of all or parts of this class must reproduce the above copyright notice, this list of conditions and
34* the following disclaimer in the documentation and/or other materials provided with the distribution and requires written permission from the Michael Thomas Flanagan:
35*
36* Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose.
37* Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software
38* or its derivatives.
39*
40***************************************************************************************/
41
42package agents.anac.y2015.agentBuyogV2.flanagan.control;
43import agents.anac.y2015.agentBuyogV2.flanagan.complex.Complex;
44import agents.anac.y2015.agentBuyogV2.flanagan.complex.ComplexPoly;
45
46public class Compensator extends BlackBox{
47
48 private double kConst = 1.0D; // K constant in compensator equation above
49 private double aConst = 1.0D; // a constant in compensator equation above
50 private double bConst = 1.0D; // b constant in compensator equation above
51
52 // Constructor - all constants = 1
53 public Compensator(){
54 super("Compensator");
55 super.sZeros = Complex.oneDarray(1);
56 super.sPoles = Complex.oneDarray(1);
57 super.setSnumer(new ComplexPoly(1.0D, 1.0D));
58 super.setSdenom(new ComplexPoly(1.0D, 1.0D));
59 super.setZtransformMethod(1);
60 super.addDeadTimeExtras();
61 }
62
63 // Constructor
64 // constants set from argument list
65 public Compensator(double kk, double aa, double bb){
66 super("Compensator");
67 this.aConst = aa;
68 this.bConst = bb;
69 this.kConst = kk;
70 super.sZeros = Complex.oneDarray(1);
71 super.sPoles = Complex.oneDarray(1);
72 super.setSnumer(new ComplexPoly(this.aConst*kConst, kConst));
73 super.setSdenom(new ComplexPoly(this.bConst, 1.0D));
74 super.setZtransformMethod(1);
75 super.addDeadTimeExtras();
76 }
77
78 public void setCoeff(double kk, double aa, double bb){
79 this.aConst = aa;
80 this.bConst = bb;
81 this.kConst = kk;
82 Complex[] num = Complex.oneDarray(2);
83 num[0].reset(this.aConst*this.kConst, 0.0D);
84 num[1].reset(this.kConst, 0.0D);
85 super.sNumer.resetPoly(num);
86 Complex[] den = Complex.oneDarray(2);
87 den[0].reset(this.bConst, 0.0D);
88 den[1].reset(1.0D, 0.0D);
89 super.sDenom.resetPoly(den);
90 this.calcPolesZerosS();
91 super.addDeadTimeExtras();
92 }
93
94 public void setK(double kk){
95 this.kConst = kk;
96 Complex co = new Complex(this.aConst*this.kConst, 0.0);
97 super.sNumer.resetCoeff(0, co);
98 co = new Complex(this.kConst, 0.0);
99 super.sNumer.resetCoeff(1, co);
100 this.calcPolesZerosS();
101 super.addDeadTimeExtras();
102 }
103
104 public void setA(double aa){
105 this.aConst = aa;
106 Complex co = new Complex(this.aConst*this.kConst, 0.0);
107 super.sNumer.resetCoeff(0, co);
108 this.calcPolesZerosS();
109 super.addDeadTimeExtras();
110 }
111
112 public void setB(double bb){
113 this.bConst = bb;
114 Complex co = new Complex(this.bConst, 0.0);
115 super.sDenom.resetCoeff(0, co);
116 this.calcPolesZerosS();
117 super.addDeadTimeExtras();
118 }
119
120 public double getA(){
121 return this.aConst;
122 }
123
124 public double getB(){
125 return this.bConst;
126 }
127
128 public double getK(){
129 return this.kConst;
130 }
131
132 // Calculate the zeros and poles in the s-domain
133 public void calcPolesZerosS(){
134 super.sZeros[0].setReal(-aConst);
135 super.sPoles[0].setReal(-bConst);
136 super.sNumerScaleFactor = BlackBox.scaleFactor(super.sNumer, super.sZeros);
137 super.sDenomScaleFactor = BlackBox.scaleFactor(super.sDenom, super.sPoles);
138
139 }
140
141 // Deep copy
142 public Compensator copy(){
143 if(this==null){
144 return null;
145 }
146 else{
147 Compensator bb = new Compensator();
148 this.copyBBvariables(bb);
149
150 bb.kConst = this.kConst;
151 bb.aConst = this.aConst;
152 bb.bConst = this.bConst;
153
154 return bb;
155 }
156 }
157
158 // Clone - overrides Java.Object method clone
159 public Object clone(){
160 return (Object)this.copy();
161 }
162}
Note: See TracBrowser for help on using the repository browser.