source: src/main/java/agents/anac/y2015/agentBuyogV2/flanagan/control/LowPassPassive.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.5 KB
Line 
1/* Class LowPassPassive
2*
3* This class contains the constructor to create an instance of
4* a low pass filter:
5* V(out) = V(in)/(1 +RCjomega)
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: 21 May 2005
14* Updated: 2 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/LowPassPassive.html
20* http://www.ee.ucl.ac.uk/~mflanaga/java/
21*
22* Copyright (c) 2005 - 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
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,
31* this list of conditions 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
35* from the Michael Thomas Flanagan:
36*
37* Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose.
38* Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software
39* or its derivatives.
40*
41***************************************************************************************/
42
43package agents.anac.y2015.agentBuyogV2.flanagan.control;
44import agents.anac.y2015.agentBuyogV2.flanagan.complex.Complex;
45import agents.anac.y2015.agentBuyogV2.flanagan.complex.ComplexPoly;
46
47public class LowPassPassive extends BlackBox{
48
49 private double resistance = 0.0D; // Resistance value, R ohms
50 private double capacitance = 0.0D; // Capacitance value, C farads
51 private double timeConstant = 0.0D; // Time constant, RC seconds
52 private boolean setR = false; // = true when resistance set
53 private boolean setC = false; // = true when capacitance set
54
55 // Constructor
56
57 // Sets time constant to unity and the order to unity
58 public LowPassPassive(){
59 super("PassiveLowPass");
60 super.sPoles = Complex.oneDarray(1);
61 super.setSnumer(new ComplexPoly(1.0D));
62 super.setSdenom(new ComplexPoly(1.0D, 1.0D));
63 super.setZtransformMethod(1);
64 super.addDeadTimeExtras();
65 this.timeConstant = 1.0D;
66 }
67
68 public void setResistance(double res){
69 this.resistance = res;
70 this.timeConstant = res*this.capacitance;
71 this.calcPolesZerosS();
72 super.sDenom = ComplexPoly.rootsToPoly(this.sPoles);
73 super.addDeadTimeExtras();
74 this.setR = true;
75 }
76
77 public void setCapacitance(double cap){
78 this.capacitance = cap;
79 this.timeConstant = cap*this.resistance;
80 this.calcPolesZerosS();
81 super.sDenom = ComplexPoly.rootsToPoly(this.sPoles);
82 super.addDeadTimeExtras();
83 this.setC = true;
84 }
85
86 public void setTimeConstant(double tau){
87 this.timeConstant = tau;
88 this.calcPolesZerosS();
89 super.sDenom = ComplexPoly.rootsToPoly(this.sPoles);
90 super.addDeadTimeExtras();
91 }
92
93 public double getResistance(){
94 if(this.setR){
95 return this.resistance;
96 }
97 else{
98 System.out.println("Class; LowPassPassive, method: getResistance");
99 System.out.println("No resistance has been entered; zero returned");
100 return 0.0D;
101 }
102 }
103
104 public double getCapacitance(){
105 if(this.setC){
106 return this.capacitance;
107 }
108 else{
109 System.out.println("Class; LowPassPassive, method: getCapacitance");
110 System.out.println("No capacitance has been entered; zero returned");
111 return 0.0D;
112 }
113 }
114
115 public double getTimeConstant(){
116 return this.timeConstant;
117 }
118
119 // Calculate the zeros and poles in the s-domain
120 protected void calcPolesZerosS(){
121 super.sPoles[0].setReal(-this.timeConstant);
122 super.sNumerScaleFactor = super.sNumer.coeffCopy(0);
123 super.sDenomScaleFactor = BlackBox.scaleFactor(super.sDenom, super.sPoles);
124 }
125
126 // Deep copy
127 public LowPassPassive copy(){
128 if(this==null){
129 return null;
130 }
131 else{
132 LowPassPassive bb = new LowPassPassive();
133 this.copyBBvariables(bb);
134
135 bb.resistance = this.resistance;
136 bb.capacitance = this.capacitance;
137 bb.timeConstant = this.timeConstant;
138 bb.setR = this.setR;
139 bb.setC = this.setC;
140 return bb;
141 }
142 }
143
144 // Clone - overrides Java.Object method clone
145 public Object clone(){
146 return (Object)this.copy();
147 }
148}
Note: See TracBrowser for help on using the repository browser.