|
|
|
Calculating Loads: Part 4 |
[Problem Solving] |
|
Posted on December 18, 2008 @ 09:18:00 AM by Paul Meagher
This is the last installment in a 4 part blog series:
Today I want to do a simple water load calculation whose purpose is to increase our confidence that the Surface Load Package developed so far is capable of generating correct answers to surface load questions
Assume the water load we want to calculate is contained within a square tank that is 10 feet long by 10 feet wide and filled to a height of 1 foot.
According to the USGS Water website, a cubic foot of water weights 62 lbs per cubic foot. If we multiply 62 lbs by the number of cubic feet of water we have, 10 x 10 x 1 = 100 ft3, then we get a total water load of 6200 lbs in our water tank.
This water_load.php script can be used to compute the same answer:
<?php
include "../SurfaceLoad.php";
// 10 x 10 surface area $load_area = "[0,0][0,10][10,10][10,0]";
// 1 foot of water $load_height = 1; // Weight of water in lbs per cubic foot volume $load_unit_weight = 62;
$load = new SurfaceLoad($load_area, $load_height, $load_unit_weight);
$load->toHTML();
?>
When you point your browser at the water_load.php script you see this:
Volume: 100 ft3
Load: 6,200 lbs
So the software generated the correct answer for a simple case whose answer we can calculate in our heads. Hopefully it works for more complex polygons :-).
One calculation that I would like to do would be one that computes the amount of energy contained in an elevated tank of water. It might begin with the surface load calculation and then combine that information with other data about the setup (i.e., height of the tank above the ground) to compute the amount of potential energy in the setup. The reasons for wanting to do this calculation have to do with a pet idea about how the energy from the tides of the Bay of Fundy might be harvested. The idea is essentially to use the high tide to fill up a massive water container that releases the water at low tide to crank hydro-electric turbines. You should also be able to harvest energy from the inflow of water into this water container. I originally ran accross this idea on the Half Bakery website and have been casually musing about it ever since.
The current paradigm for harvesting Fundy tidal energy involves installing underwater windmill-like turbines. This paradigm is apparently encountering some harsh realities where recent monitoring of the Fundy bottom suggests that massive mud-imbued chunks of ice can potentially ride along the bottom and smash into the turbines. Perhaps we should look at a different paradigm for harvesting power from the massive Fundy tides? Above-ground hydroelectric? How massive would this water container have to be? How much power could be generated?
Another avenue that I would like to explore at some point would be adapting the concept of "load" to other domains: solar loads, wind loads, ecological loads, etc...
I don't think I will have the time to seriously explore these ideas so I'll end this "Calculating Loads" blog series for now.
|
|
Permalink |
|
Calculating Loads: Part 3 |
[Problem Solving] |
|
Posted on December 17, 2008 @ 09:16:00 AM by Paul Meagher
This blog is part of a blog series:
In my last blog I expressed some concern about making a mistake when specifying the polygonal coordinates of my driveway. One way to help alleviate that concern is to take the same coordinates I used when computing the polygonal area and plug them into a program that will generate a visualization of that polygonal area. A mis-specified coordinate will often show up as an obvious graphical anomoly as I discovered when I first started drawing the polygon coordinates for my driveway.
Here is the draw_polygon.php script that I point my browser at to visualize my driveway:
<?php
include "../DrawPolygon.php";
$poly = new DrawPolygon;
$poly->canvas($width=390, $height=120);
$polygon = "[0,0][0,28][15,23.5][97,26][97,34][100.5,34]"; $polygon .= "[100.5,31][116,31][116,26][108,26][108,0][97,0]"; $polygon .= "[15,4.5]";
$poly->draw($polygon, $scale=3, $filled=false); ?>
Here is the DrawPolygon class that houses the input parsing and drawing commands.
<?php /* * @author Paul Meagher * @modified Dec 17, 2008 * * Some code lifted from: * * @see http://www.design-ireland.net */
define('IMAGE_FLIP_HORIZONTAL', 1); define('IMAGE_FLIP_VERTICAL', 2); define('IMAGE_FLIP_BOTH', 3);
Class DrawPolygon {
var $X = array(); var $Y = array(); var $img;
function canvas($width, $height) { // set the HTTP header type to PNG header("Content-type: image/gif"); // setup a canvas $this->img = ImageCreateTrueColor($width, $height); // switch on image antialising if it is available ImageAntiAlias($this->img, true); // set background to white $white = ImageColorAllocate($this->img, 255, 255, 255); ImageFillToBorder($this->img, 0, 0, $white, $white); } /** * Easier and more intuitive to specify coordinates in * square bracket format than X and Y array format. * * The function that computes the polygonal area uses * X and Y arrays so this converter puts the coordinates * into the required format. */ function convertStringToXYArrays($v) { $vertices = explode("]", $v); $num_vertices = count($vertices) - 1; for($i=0; $i < $num_vertices; $i++) { $coord = trim(str_replace('[', '', $vertices[$i])); list($this->X[$i], $this->Y[$i]) = explode(",", $coord); } } /* * Adds polygon to canvas. * * Option to scale the size of the image and * fill in the polygon outline or not. */ function draw($vertices, $scale=1, $filled=true) { $this->convertStringToXYArrays($vertices); $black = ImageColorAllocate($this->img, 0, 0, 0); // the number of vertices for our polygon $num_of_points = count($this->X); for($i=0; $i < $num_of_points; $i++) { $points[] = $this->X[$i] * $scale; $points[] = $this->Y[$i] * $scale; } if ($filled) { // now draw out the filled polygon ImageFilledPolygon($this->img, $points, $num_of_points, $black); } else { // draw out an empty polygon ImagePolygon($this->img, $points, $num_of_points, $black); } ImageGIF($this->img); // destroy the reference pointer to the image in memory to free // up resources ImageDestroy($this->img);
} }
?>
The draw_polygon.php script in conjuction with the DrawPolygon.php class generates the following visualization of my driveway:
This visualization corresponds to many of the features of my driveway and the proportions seem about right. I would create a bigger blow up than I used in this blog if I were really studying the correspondence (i.e., increase the height and width of the canvas and increase the scale factor).
One problem I have with the visualization is the orientation of the graphic. I'd like to figure out the math to transform the coordinates to match my preferred orientation for the driveway visualization (i.e., flip it accross the x axis). Another alternative is to setup my co-ordinates differently now that I am aware of where the (0,0) point is for PHP's ImagePolygon() function (top left corner of screen).
Tomorrow I will finish off this series by applying the software developed so far to doing a few other load calculations.
|
|
Permalink |
|
Calculating Loads: Part 2 |
[Problem Solving] |
|
Posted on December 16, 2008 @ 09:17:00 AM by Paul Meagher
This blog is part of a blog series:
In my last blog, I mentioned that I was dissatisfied with my method for approximating the irregular surface area of my driveway. I approximated the area using the formula for a trapezoid, but started to think that approximating the driveway shape with a polygon would give me more accuracy in my driveway snow load calculation.
To approximate the shape of my driveway with a polygon I chose the right side of the drive way entrance as the starting point (0,0) and specified the coordinates of each remaining point in a clockwise fashion. Each remaining point was a point where the perimeter of the driveway changed direction. It took a bit of measuring to get all these coordinates figured out. Each coordinate is the X and Y distance, in feet, from the 0,0 reference point. These coordinates are being loaded into a string variable called
$load_area in the surface_load.php script below:
<?php
include "../SurfaceLoad.php";
// Specify the closed polygonal area using co-ordinates of each // bend around the load area $load_area = "[0,0][0,28][15,23.5][97,26][97,34][100.5,34]"; $load_area .= "[100.5,31][116,31][116,26][108,26][108,0][97,0]"; $load_area .= "[15,4.5]";
// Ten inches of snow can be expressed in foot units this way $load_height = 10/12; // Weight of snow in lbs per cubic foot volume $load_unit_weight = 20;
$load = new SurfaceLoad($load_area, $load_height, $load_unit_weight);
$load->toHTML();
?>
The script calls a class SurfaceLoad that supplies the logic used to accept the input parameters, compute load based on these parameters, and output the surface load volume and total weight.
<?php /** * Used to compute surface load volume and weight * on a flat polygonal surface. Use at your own * risk. No warranties or guarantees. * * @author Paul Meagher * @modified Dec 16, 2008 */ class SurfaceLoad {
var $X = array(); var $Y = array();
var $area = 0; var $height = 0; var $volume = 0; var $unit_weight = 0; var $total_weight = 0; /** * Constructor * * Computes all the relevant quantities. */ function SurfaceLoad($vertices, $height, $weight) { $this->convertStringToXYArrays($vertices); $this->area = $this->computePolygonArea($this->X, $this->Y); $this->height = $height; $this->unit_weight = $weight; $this->volume = $this->area * $this->height; $this->total_weight = $this->volume * $this->unit_weight; } /** * Easier and more intuitive to specify coordinates in * square bracket format than X and Y array format. * * The function that computes the polygonal area uses * X and Y arrays so this converter puts the coordinates * into the required format. */ function convertStringToXYArrays($v) { $vertices = explode("]", $v); $num_vertices = count($vertices) - 1; for($i=0; $i < $num_vertices; $i++) { $coord = trim(str_replace('[', '', $vertices[$i])); list($this->X[$i], $this->Y[$i]) = explode(",", $coord); } }
/** * Compute the area of specfied polygon. Ported from: * * @see http://geosoft.no/software/geometry/Geometry.java.html * * @param array $x x coordinates of a polygon * @param array $y y coordinates of a polygon * @return float area of polygon */ function computePolygonArea($x, $y) { $n = count($x); $area = 0.0; for ($i=0; $i < $n-1; $i++) $area += ($x[$i]*$y[$i+1])-($x[$i+1]*$y[$i]); $area += ($x[$n-1]*$y[0]) - ($x[0]*$y[$n-1]); $area *= 0.5; // hack: was getting negative numbers so I // applied the absolute value function return abs($area); } /** * Convenience function for outputting load volume in * cubic feet and load weight in lbs. */ function toHTML($decimals=0) { $volume = number_format($this->volume, $decimals); $load = number_format($this->total_weight, $decimals); ?> <p> Volume: <?php echo $volume ?> ft<sup>3</sup> </p> <p> Load: <?php echo $load ?> lbs </p> <?php } }
?>
The new and improved snow load calculator outputted the following result:
Volume: 2,158 ft3
Load: 43,150 lbs
Which isn't really that much different than my first crude attempt at approximating the snow load.
So at this point I should have left well-enough alone, but no, I had to continue on my quest for the best driveway snow load calculator in the world :-) In tomorrows installment, I will discuss the DrawPolygon.php class I created that allows me to verify that the coordinates used in my calculations actually look like the shape of my driveway.
BTW, if anyone discovers anything amiss with my calculations I would appreciate a comment about it.
|
|
Permalink |
|
Calculating Loads: Part 1 |
[Problem Solving] |
|
Posted on December 15, 2008 @ 09:11:00 AM by Paul Meagher
This blog is part of a blog series:
This week I am going to discuss some recreational math I've been doing on the topic of "Calculating Loads".
It all started about 3 weeks ago when we got a heavy snowfall. I started shovelling the snow and decided to take some measurements of my driveway dimensions to see if I could figure out the total weight of the snow I was displacing from the paved driveway to the lawn area adjacent the driveway.
I measured the snow to be about 10 inches high and of fairly uniform thickness throughout the driveway. I estimated the unit weight of the snow to be about 20 lbs per cubic foot (the snow was damp and compacted). Later I learned that one method of measuring the weight would have been to outline the 2D area of a cubic foot in the snow, record the height of the snow, shovel the snow into a garbage bag, and measure the weight of the garbage bag. Perhaps I'll try this method on another snow removal day. It will give me something to think about whilst I am shovelling.
My driveway has an irregular shape and to simplify the calculations I used a trapezoidal shape to approximate its dimensions: 19 feet wide at the driveway entrance and 33 feet wide at the end which is marked by our garage entrance. I didn't measure the length of the driveway but estimated it to be about 100 feet long. With all these measurements and estimates in place, I was ready to develop a php-based script called snow_load.php to calculate a total volume and weight of snow on my driveway, aka, the snow load. The snow load calculation would give me a sense of how much of a workout it was to displace the snow off the driveway.
<?php /** * @script snow_load.php * @author Paul Meagher * * @see http://argyll.epsb.ca/jreed/math9 * /strand3/trapezoid_area_per.htm */
// Using foot units $width_1 = 33; $width_2 = 19; $length = 100;
// Ten inches of snow can be expressed in foot // units this way $height = 10/12;
// Weight of snow per cubic foot volume $lbs_per_cubic_foot = 20;
// First compute area using trapezoid area // formula $area = 0.5 * $length * ($width_1 + $width_2);
// Next multiply area by height to get cubic foot // volume $volume = $area * $height;
// Total weight of snow removed $weight = $volume * $lbs_per_cubic_foot;
// Number of decimal places for output $decimals = 0; ?>
<p> Volume of snow is <?php echo number_format($volume, $decimals) ?> ft<sup>3</sup>. </p>
<p> Total weight of snow removed was <?php echo number_format($weight, $decimals) ?> lbs. </p>
When I pointed my browser at the webserver where the script resided, it generated the following output:
Volume of snow is 2,167 ft3.
Total weight of snow removed was 43,333 lbs.
It was at this point that I should have left good-enough alone and accepted this result, instead I recreated on the idea of attaining more accuracy in my calculation by approximating the shape of the driveway with a polygon. Tomorrow I will talk about that calculation when I discuss a generalized SurfaceLoad.php class. After that I will discuss some visualization work I did which I packaged into a DrawPolygon.php class.
|
|
Permalink |
| |