-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
320 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
import process.SecondOrderSystem; | ||
import gui.Gui; | ||
import javafx.application.Application; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
|
||
/** | ||
* Created by marlon on 6/13/14. | ||
*/ | ||
public class Main { | ||
public class Main extends Application { | ||
public static void main(String[] args){ | ||
launch(args); | ||
} | ||
|
||
@Override | ||
public void start(Stage primaryStage) throws Exception { | ||
Gui gui = new Gui(); | ||
Scene scene = new Scene(gui); | ||
primaryStage.setScene(scene); | ||
primaryStage.show(); | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
src/main/java/conicaltank/ConicalTankTransferFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package conicaltank; | ||
|
||
import javafx.beans.property.DoubleProperty; | ||
import javafx.beans.property.DoublePropertyBase; | ||
|
||
/** | ||
* Created by marlon on 6/18/14. | ||
* | ||
* G(s) = gain | ||
* --------- | ||
* tau*s + 1 | ||
*/ | ||
public class ConicalTankTransferFunction { | ||
|
||
// PROPERTIES // | ||
private static final double HEIGHT = 10.0; | ||
private static final double RADIUS = 5.0; | ||
private static final double GRAVITY = 9.8; | ||
private static final double OBSTRUCTION = 1.5; | ||
|
||
private DoubleProperty heightOperationPoint; | ||
private DoubleProperty inflowOperationPoint; | ||
|
||
private double gain; | ||
private double tau; | ||
|
||
// CONSTRUCTOR // | ||
public ConicalTankTransferFunction() { | ||
this.heightOperationPoint = new DoublePropertyBase(0.0001) { | ||
@Override protected void invalidated() { | ||
set(get()); | ||
} | ||
@Override public Object getBean() { | ||
return this; | ||
} | ||
@Override public String getName() { | ||
return "heightOperationPoint"; | ||
} | ||
}; | ||
this.inflowOperationPoint = new DoublePropertyBase(1.0) { | ||
@Override | ||
protected void invalidated() { | ||
recalculate(); | ||
set(get()); | ||
} | ||
@Override public Object getBean() { | ||
return this; | ||
} | ||
@Override public String getName() { | ||
return "inflowOperationPoint"; | ||
} | ||
}; | ||
recalculate(); | ||
} | ||
|
||
// METHODS // | ||
private void recalculate(){ | ||
double alpha = ((9/2) * | ||
(OBSTRUCTION * Math.pow(HEIGHT,2) * Math.sqrt(2*GRAVITY) * Math.pow(heightOperationPoint.get(), -5/2)) / | ||
(2 * Math.PI * Math.pow(RADIUS,2))) - | ||
((6 * Math.pow(HEIGHT,2) * inflowOperationPoint.get() * Math.pow(heightOperationPoint.get(),-3)) / | ||
(Math.PI * Math.pow(RADIUS,2))); | ||
|
||
double beta = (3 * Math.pow(HEIGHT,2) * Math.pow(heightOperationPoint.get(),-2)) / | ||
(Math.PI * Math.pow(RADIUS,2)); | ||
|
||
gain = beta / alpha; | ||
tau = 1 / alpha; | ||
} | ||
|
||
// SETTERS AND GETTERS // | ||
public double getGain() { | ||
recalculate(); | ||
return gain; | ||
} | ||
public double getTau() { | ||
recalculate(); | ||
return tau; | ||
} | ||
|
||
|
||
public double getHeightOperationPoint() { | ||
return heightOperationPoint.get(); | ||
} | ||
public DoubleProperty heightOperationPointProperty() { | ||
return heightOperationPoint; | ||
} | ||
public void setHeightOperationPoint(double heightOperationPoint) { | ||
this.heightOperationPoint.set(heightOperationPoint); | ||
} | ||
|
||
public double getInflowOperationPoint() { | ||
return inflowOperationPoint.get(); | ||
} | ||
public DoubleProperty inflowOperationPointProperty() { | ||
return inflowOperationPoint; | ||
} | ||
public void setInflowOperationPoint(double inflowOperationPoint) { | ||
this.inflowOperationPoint.set(inflowOperationPoint); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,82 @@ | ||
package process; | ||
|
||
import javafx.beans.property.DoubleProperty; | ||
import javafx.beans.property.LongProperty; | ||
import javafx.beans.property.SimpleDoubleProperty; | ||
import javafx.beans.property.SimpleLongProperty; | ||
|
||
/** | ||
* Created by marlon on 6/16/14. | ||
* | ||
* The transfer function is in form: | ||
* | ||
* G(s) = zero | ||
* ------ | ||
* s+pole | ||
* G(s) = gain | ||
* --------- | ||
* tau*s + 1 | ||
* | ||
*/ | ||
public class FirstOrderSystem { | ||
private double zero; | ||
private double pole; | ||
private DoubleProperty input; | ||
private DoubleProperty output; | ||
private DoubleProperty gain; | ||
private DoubleProperty tau; | ||
private LongProperty samplingTime; | ||
|
||
public FirstOrderSystem(double zero) { | ||
this.zero = zero; | ||
public FirstOrderSystem() { | ||
input = new SimpleDoubleProperty(this, "input", 0.0); | ||
output = new SimpleDoubleProperty(this, "output", 0.0); | ||
gain = new SimpleDoubleProperty(this, "gaing", 0.0); | ||
tau = new SimpleDoubleProperty(this, "tau", 0.0); | ||
samplingTime = new SimpleLongProperty(this, "samplingTime", 100); | ||
} | ||
|
||
public double getZero() { | ||
return zero; | ||
public double getInput() { | ||
return input.get(); | ||
} | ||
public DoubleProperty inputProperty() { | ||
return input; | ||
} | ||
public void setInput(double input) { | ||
this.input.set(input); | ||
} | ||
|
||
public void setZero(double zero) { | ||
this.zero = zero; | ||
public double getOutput() { | ||
return output.get(); | ||
} | ||
public DoubleProperty outputProperty() { | ||
return output; | ||
} | ||
public void setOutput(double output) { | ||
this.output.set(output); | ||
} | ||
|
||
public double getPole() { | ||
return pole; | ||
public double getGain() { | ||
return gain.get(); | ||
} | ||
public DoubleProperty gainProperty() { | ||
return gain; | ||
} | ||
public void setGain(double gain) { | ||
this.gain.set(gain); | ||
} | ||
|
||
public void setPole(double pole) { | ||
this.pole = pole; | ||
public double getTau() { | ||
return tau.get(); | ||
} | ||
public DoubleProperty tauProperty() { | ||
return tau; | ||
} | ||
public void setTau(double tau) { | ||
this.tau.set(tau); | ||
} | ||
|
||
public long getSamplingTime() { | ||
return samplingTime.get(); | ||
} | ||
public LongProperty samplingTimeProperty() { | ||
return samplingTime; | ||
} | ||
public void setSamplingTime(long samplingTime) { | ||
this.samplingTime.set(samplingTime); | ||
} | ||
} | ||
} |
Oops, something went wrong.