-
Notifications
You must be signed in to change notification settings - Fork 12
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
17 changed files
with
1,617 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
global DR_GROUP_ID | ||
global drg | ||
try: | ||
if DR_GROUP_ID >= 0: | ||
DR_GROUP_ID += 1 | ||
except NameError: | ||
DR_GROUP_ID = 0 | ||
drg = [] | ||
|
||
drg.append(trick.DRAscii("WaterClock")) | ||
drg[DR_GROUP_ID].set_freq(trick.DR_Always) | ||
drg[DR_GROUP_ID].set_cycle(0.01) | ||
drg[DR_GROUP_ID].set_single_prec_only(False) | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.time") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.input_flow") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_clock_spout_flowrate") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_overflow_flowrate") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_bucket_net_flow") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_bucket_depth") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_bucket_diam") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_overflow_height") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_overflow_diameter") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_clock_spout_height") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_clock_spout_diameter") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.timer_bucket_depth") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.timer_bucket_diam") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_bucket_vol") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.intake_water_level") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.timer_bucket_vol") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.timer_water_level") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.tick_gap") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.total_ticks") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.current_tick") | ||
drg[DR_GROUP_ID].add_variable("dyn.waterclock.gravity") | ||
drg[DR_GROUP_ID].set_max_file_size(1 * 1073741824) # multiply converts GiB to B --Dr. Dre | ||
trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer) | ||
drg[DR_GROUP_ID].enable() |
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,62 @@ | ||
# SIM_WaterClock | ||
|
||
--- | ||
|
||
SIM_WaterClock simulates a simple water clock. A water clock is a clock that measures time utilizing the flow of water. There exists different designs for water clocks, but this one uses a basic two bucket design. | ||
|
||
The first bucket is called the intake bucket. The intake bucket receives water from an external source of variable flow rate. In the real world this might be piped in from a stream for example. In this sim, the water source (input_flow) is a variable range from 0 to 10 liters/s that can be arbitrarily adjusted via the GUI. The intake bucket contains two spouts, a clock spout and an overflow spout. Both spouts are cylinders defined by their width and height on the intake bucket. The clock spout pours water into the second bucket (timer bucket), while the overflow spout empties water into the void. | ||
|
||
In an ideal water clock, by balancing the dimensions of the intake bucket, the clock spout, overflow spout, and the input flow rate, the flow rate of the clock spout (and therefore the input flow rate of the timer bucket) will be constant. Given a constant flow rate into the timer bucket, we can correlate water level with time passed. | ||
|
||
Assumptions: | ||
* For the purpose of determining if a pipe is submerged, the pipe will be treated as a single point at its center. | ||
* When the timing bucket is filled, a magical siphon will drain it instaneously. This prevents the need to simulate the recalibration of the clock. | ||
* Buckets and spouts are perfectly cylindrical. | ||
|
||
### A Brief History | ||
The water clock (or clepsydra to the ancient Greek) is a device used to measure time through the displacement of water. It is not known precisely when the earliest water clocks were developed, but they have been discovered to exist in various parts of the world as early as the 16th century BC. These early designs were relatively simple compared to later designs, consiting of a bowl with markings to indicate time passing as the bowl either filled or drained. | ||
|
||
Water clocks remained a prominent timekeeping device until the 17th century when better methods of timekeeping were developed. Over those many centruies, different cultures innovated on the design of the early water clocks. Of particular note were the contributions of the Greek inventor Ctesibius in the 3rd century BC. Ctesibius innovated on the water clock by making it largely automatic. Prior to Ctesibius, water clocks needed to be consistently refilled/emptied by hand. Furthermore, if a water clock had indicators marking the position of the sun, they would need to be manually adjusted for different seasons. Ctesibius automated both these processes. | ||
|
||
Ctesibius automated the draining process with a siphon akin to Pythagorean cup. This siphon would empty over a water wheel, which powered a series of gears that would turn a cylinder. The cylinder had a row of irregular rings drawn around it, meant to correlate with the position of the sun throughout the seasons. Each day, as the water clock would fill it would accurately indicate the position of the sun, drain itself at the end of the day, and adjust the cylinder to be accurate for the next day. | ||
|
||
### Building the Simulation | ||
After building trick, in the SIM\_waterclock directory run the command **trick-CP** to build the sim. When it's complete, you should see: | ||
|
||
``` | ||
Trick Build Process Complete | ||
``` | ||
To build the graphics client **cd** into models/graphics/ and run **mvn package**. This isn't necessary for the sim to run, but will provide a visual display of the water clock. | ||
|
||
### Running the Simulation | ||
In the SIM_waterclock directory: | ||
|
||
``` | ||
% S_main_*.exe RUN_test/input.py | ||
``` | ||
The Sim Control Panel, and a GUI called "Water Clock" should appear. | ||
|
||
![Water Clock graphics client at the start of a run.](images/WaterClockStart.png) | ||
|
||
Click the Start on the Trick Sim Control Panel. The Water Clock should begin to fill up. | ||
|
||
![Water Clock graphics client mid-run.](images/WaterClockRunning.png) | ||
|
||
The only control on the GUI client is a slider which changes the flow rate of water into the water clock. It can be set anywhere from no flow up to 10 liters per second (10,000 cm^3^/s). | ||
|
||
By default, the water clock will count out 60 "ticks" at a little over 1 second a tick. See if you can clibrate the water clock to count out a proper minute (1 second a tick). | ||
|
||
### Configurable Parameters | ||
The following parameters are meant to be configured by the user. They consist of the dimensions of the buckets, the dimensions and placement of the intake bucket spouts, and the number of time ticks. | ||
|
||
Variable | Type | Units | ||
----------------------------------------------------------------------|----------------|------- | ||
dyn.waterclock.intake_bucket_depth | double | m | ||
dyn.waterclock.intake_bucket_diam | double | m | ||
dyn.waterclock.intake_overflow_height | double | m | ||
dyn.waterclock.intake_overflow_diameter | double | m | ||
dyn.waterclock.intake_clock_spout_height | double | m | ||
dyn.waterclock.intake_clock_spout_diameter | double | m | ||
dyn.waterclock.timer_bucket_depth | double | m | ||
dyn.waterclock.timer_bucket_diam | double | m | ||
dyn.waterclock.total_ticks | int | -- |
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,44 @@ | ||
exec(open("Modified_data/my_waterclock.dr").read()) | ||
|
||
trick.frame_log_on() | ||
trick.real_time_enable() | ||
trick.exec_set_software_frame(0.1) | ||
trick.itimer_enable() | ||
trick.exec_set_enable_freeze(True) | ||
trick.exec_set_freeze_command(True) | ||
trick.sim_control_panel_set_enabled(True) | ||
|
||
dyn.waterclock.input_flow = 1000.0 | ||
|
||
dyn.waterclock.intake_bucket_depth = 70.0 | ||
dyn.waterclock.intake_bucket_diam = 40.0 | ||
|
||
dyn.waterclock.intake_overflow_height = 60.0 | ||
dyn.waterclock.intake_overflow_diameter = 25.0 | ||
|
||
dyn.waterclock.intake_clock_spout_height = 15.0 | ||
dyn.waterclock.intake_clock_spout_diameter = 20.0 | ||
|
||
dyn.waterclock.timer_bucket_depth = 100.0 | ||
dyn.waterclock.timer_bucket_diam = 45.0 | ||
|
||
dyn.waterclock.total_ticks = 60 | ||
|
||
trick.message_unsubscribe(trick_message.mcout) | ||
|
||
# ========================================== | ||
# Start the Satellite Graphics Client | ||
# ========================================== | ||
varServerPort = trick.var_server_get_port(); | ||
WaterClockDisplay_path = "models/graphics/build/WaterClockDisplay.jar" | ||
|
||
if (os.path.isfile(WaterClockDisplay_path)) : | ||
WaterClockDisplay_cmd = "java -jar " \ | ||
+ WaterClockDisplay_path \ | ||
+ " " + str(varServerPort) + " &" ; | ||
print(WaterClockDisplay_cmd) | ||
os.system( WaterClockDisplay_cmd); | ||
else : | ||
print('==================================================================================') | ||
print('Display needs to be built. Please \"cd\" into ../models/graphics and type \"mvn package\".') | ||
print('==================================================================================') |
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,36 @@ | ||
/************************TRICK HEADER************************* | ||
PURPOSE: | ||
(S_define file for SIM_waterclock_numeric) | ||
LIBRARY DEPENDENCIES: | ||
( | ||
(waterclock/src/waterclock_init.c) | ||
(waterclock/src/waterclock_numeric.c) | ||
(waterclock/src/waterclock_shutdown.c) | ||
) | ||
*************************************************************/ | ||
|
||
#include "sim_objects/default_trick_sys.sm" | ||
##include "waterclock/include/waterclock_numeric.h" | ||
|
||
class WaterClockSimObject : public Trick::SimObject { | ||
|
||
public: | ||
WATERCLOCK waterclock; | ||
|
||
WaterClockSimObject() { | ||
("default_data") waterclock_default_data( &waterclock ) ; | ||
("initialization") waterclock_init( &waterclock ) ; | ||
("derivative") waterclock_deriv( &waterclock ) ; | ||
("integration") trick_ret= waterclock_integ( & waterclock ) ; | ||
("shutdown") waterclock_shutdown( &waterclock ) ; | ||
("dynamic_event") waterclock_tick_change( &waterclock ) ; | ||
("dynamic_event") waterclock_overflow_timer( &waterclock ) ; | ||
} | ||
} ; | ||
|
||
WaterClockSimObject dyn ; | ||
|
||
IntegLoop dyn_integloop (0.01) dyn ; | ||
void create_connections() { | ||
dyn_integloop.getIntegrator(Runge_Kutta_4, 4); | ||
} |
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,2 @@ | ||
TRICK_CFLAGS += -Imodels | ||
TRICK_CXXFLAGS += -Imodels |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
|
||
all: | ||
mvn package | ||
|
||
clean: | ||
rm -rf build |
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,121 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>trick-java</groupId> | ||
<artifactId>trick-java</artifactId> | ||
<version>23.0.0-beta</version> | ||
|
||
<name>trick-java</name> | ||
|
||
<url>https://github.com/nasa/trick</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
||
<finalName>WaterClockDisplay</finalName> | ||
|
||
<directory>build</directory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.1.1</version> | ||
<configuration> | ||
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable> | ||
<destDir>../../share/doc/trick/java</destDir> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | ||
|
||
<plugins> | ||
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
|
||
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.0</version> | ||
<configuration> | ||
<compilerArgs> | ||
<arg>-g</arg> | ||
<arg>-Xlint:unchecked</arg> | ||
<arg>-Xlint:deprecation</arg> | ||
</compilerArgs> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<!-- Build an executable JAR --> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<classpathPrefix>lib/</classpathPrefix> | ||
<mainClass>WaterClockDisplay</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.1</version> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.2</version> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
</plugin> | ||
|
||
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.7.1</version> | ||
</plugin> | ||
|
||
<!-- | ||
<plugin> | ||
<artifactId>maven-project-info-reports-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
--> | ||
|
||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
Oops, something went wrong.