//
//CAESAR. Copyright (C) 2005 T.J.Coulthard
//This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (http://www.gnu.org/copyleft/gpl.html) for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// 10/06/03 : Visual Caesar version 1.2 10th June 2003
// Same as CAESAR21.c or TRACER21.c but now migrated to Visual C#.net
// Some rather strange programming in places - e.g graphics and event handling,
// but the main CAESAR code is the same. Vis C# gives me the chance to easily use
// dynamic arrays (never got to grip with malloc) to assign many of the variables
// at run time when the user clicks go!
// I hope you find this code of use. Tom
// unknown date : v1.9
// form1v9.cs now has spreading of water across number of cells in front.
// For the moment disabled lateral erosion
// Mid Sept 04 :
// Added wilcock and Crowe surface hiding sediment transport law.
// With this is code to calcualte the D50.
// 29/09/04
// Changed grass grow routine, so now adds volume and subtracts from other layers
// within the grow grass routine as in the normal sort active it removese the grass first
// Also added a small line in lateral that allows water to 'evaporate' which prevents
// water 'trapped' in a hollow remaining there
//
// 30/09/04 : 2v5a
// XML data loader/saver added by Jeremy Walsh from NIWA Christchurch.
// 01/10/04 : 2v6
// Am trying to use energy gradient instead of bed slope for erosion
// this has been added but not used yet.. given up on this now. back to old method
// 04/10/04 : 2v7
// Changed erosion routines, so that it calculates seiment tranport from a cell (total)
// according to max slope and depth, which then is distributed according to slope (20%)
// and discharge direction (80%)
// 05/10/04 : 2v8
// 15/11/04 :
// Same as 2v7, but distributes 50/50 by bedslope and by Q direction for the two smallest grain sizes
// Needs to have better defined vegetation routines.
// 09/01/05 : v.3.8
// Changing how vegetation is added or represented.
// 20/01/05 : v3.9
// MJ: rearranged input display
// MJ: added statusbar for on-screen outputs
// MJ: CASTCHMENT_FILE can be specified (new entryfield: TimeseriesBox)
// MJ: added iteration output to file (ITERATION_FILE)
// TC: adjusted routing procedures to account for hydrological input with 8 sweeps (instead of 4)
// TC: blocked out the random rain bit...
// TC: added lateral2()
// TC: adjusted creep and grassgrow rates
// 27/01/05 : v4.0
// TC: amended lateral2() now traces wet edges inanticipation of inside/outside edge of bend recognition
// TC: added wet edges to display routine
// TC: changed drawwater() so that now uses fillrectangle, so draws all the data properly, instead of over thick lines on rectangle edges
// MJ: made iteration output and time-series output optional (checkboxes)
// MJ: updated XML routines for opening and saving config files (backwards compatible)
// MJ: adjusted init_route to remove discharge spikes
// MJ: removed bugs in output_data()
// 03/02/05 : v4.0.MJ02
// v4.0.MJ02a : removed non-essential pop-up windows
// v4.0.MJ02b : corrected entrainment formula in erode_w()
// v4.0.MJ02c : rearranged terms in Q distribution in erode_w()
// v4.0.MJ02d : further rearranged terms in Q distribution in erode_w()
// v4.0.MJ02e : rearranged terms in slope distribution in erode_w()
// v4.0.MJ02f : further rearranged terms in slope distribution in erode_w()
// v4.0.MJ02g : move calculation of slopesum outside loop in erode_w()
// v4.0.MJ02h : general tyding up of erode_w()
// v4.0.MJ02i : treshhold check outside erode_w()
// v4.0.MJ02j : added *DX to calculation of temp_dist in erode_w()
// v4.0.MJ02k : removed *DX to calculation of temp_dist in erode_w()
// v4.0.MJ02k1 : increased number of scans in peak-discharge removal in init_route()
// v4.0.MJ02k2 : further increased number of scans in peak-discharge removal in init_route()
// v4.0.MJ02k3 : removed peak-discharge removal in init_route()
// 21/02/05 : v4.0.MJ03
// MJ : added suspended sediment routines in erode() and erode4()
// 24/02/05 : v4.0.MJ04
// MJ : fixed bugs in suspended sediment routines
// 15/03/05 : v.4.0.MJ05
// MJ : fixed bugs in output_data()
// MJ : added output of j_mean to output_data()
// MJ : changed evaporation to parameter (also in XML handling)
// 23/03/05 : v.4.2.MJ01
// MJ : fixed bugs in output_data()
// MJ : added output of j_mean to output_data()
// MJ : changed evaporation to parameter (also in XML handling)
// TJ : added routine for input of susp sediment
// TJ : fixed bugs in flow sweeping routines
// TJ : changed values of some hardcoded thresholds
// TJ : added array water_depth2, to keep track of unsmoothed water depths
// TJ : reorganized treatment of grass in addGS()
// TJ : reduced fine sediment in substrata
// 25/03/05 : v.4.2.MJ03
// MJ : bug fix in susp sediment input in erode()
// MJ : bug fix in updating of temp and elev in erode()
// MJ : restructure updating of temp and elev in erode()
// 29/03/05 : v.4.2.MJ03
// MJ : bug fixes in j_mean output
// 29/03/05 : v.4.3.MJ01
// TJ : bug fixes
// TJ : preparing strata changes
// 04/04/05 : v4.3.MJ02
// MJ : changing sort_active()
// 08/04/05 : v4.3.MJ03
// TJ : new sort_active2() to replace sort_active(), different treatment of layers
// 16/04/05 : v4.3.MJ03b
// MJ : output of d50 in top layer
// 10/05/05 : v4.9
// MJ : generalized suspended sediment routine to multiple grain sizes
// MJ : adjusted interface and XML reading accordingly
// MJ : reorganized bits of code: erode_w(), sort_active2(), erode()
// TJ : added lateral erosion routine: lateral2() - not active in this version
// TJ : altered way vegetation is handled: erode_w()
// MJ : vegetation critical shear stress can be user-defined
// MJ : adjusted interface and XML reading accordingly
// 17/05/05 : v4.91
// TJ : sediment now routed according to lateral gradient as well : erode_w() and lateral2()
// JOE : display option for DEM
// JOE : color conversion HSV to RGB : Color_HSVtoRGB()
// JOE : calculation of soil saturation : calc_soilsaturation()
// JOE : calculation of flow velocity : calc_flowvelocity
// JOE : fixed bug in output of iteration file
// 24/05/05 : v4.91b
// MJ : added option to read grid dimensions form DEM header
// MJ : updated XML to account for above changes
// MJ : added support for saving screen size in XML
// MJ : fixed bug in display of grass
// MJ : disabled lateral2(), calc_flowvelocity() and calc_soilsaturation() in this version
// 06/07/05 : v4.91c
// MJ : added code to drop out sediment when water evaporates
// MJ : fixed bug in output of suspended sediment
// 07/07/05 : v4.91d
// MJ : fixed bug in deposition of sediment
// 1/8/05: v4.93
// TJC : Bug fixed in suspended sediment (MJ) that caused errors when more than 2 SS fractions selected
// TJC : Version 4.92 has been superceded before release
// TJC : This version contains a lateral erosion routine (lateral2) which is still very experimental
// Its still commented out - and redirected to lateral. If you want more info on how to experiemtn with it
// and what the parameters do, contact Tom.
//
// TJC : Changed values used in erode_w - erosion is now driven by slopes from unsmoothed water surface, but
// depth from the smoothed value. Gets around problems of small blockages - but does make erosion/dep more agressive
// this can easily be changed by changing water_depth[x,y] where erode_w is called in erode_depo
// 3/11/05 v.4.93n
// TJC : Found error in calcualting drainage area - now fixed - was including -9999 cells
// also changed display menu to show drainage area instead of pits
// 6/11/05 v.4.93p
// TJC :Added lateral tab - so user can switch between old and new lateral scheme
// 9/11/05 v.4.93q
// TJC : Found error in route down, routing to x+1,y instread of x+n,y
// 4/01/06 v 5.1
// TJC: lateral erosion semi finalised. Still very much a prototype, but working in principle
// Key features and changes.
// 1. Tau is now calcualted in calc_flow_direction routine
//
// 2. Tau is now smoothed (see function call in erode_depo).
//
// 3. New routines to calculate slopes - bedslope, water surface slope old water surface slope etc..
// these are now called from the routines where needed (e.g route down etc.. ) At the moment average bedslope is
// still used to calc water surface, as ws slope led to erratuc - fluctuating surface. Erosion slopes can be changed
// between bedslope and ws slope (new check boxes). I recommend using the ws slope with lateral method 2 (new method)
// as if you use bed slope, then lateral erosion banks material up on the inside of bends - which then increases the local slope,
// increasing Tau, eroding the material back down again -so the lateral slope and bedslope compete against each other.
// This leads to a ahigher Tau on the inside of the bend - incorrect. If you make the slope ws slope, then the deeper outside of
// a bend leads to a higher Tau which increases the depth - the feedback we probably see in the field.
//
// 4. Lateral erosion. this is calcualted using the radius of curvature, calculated in the method as described in
// Coulthard & Van de Wiel, 2006 (ESP&L). 3 options are given in the model. The main difference from the paper, is
// that in this version it uses just manhattan neighbours to calc the Rc, due to problems with single thread
// diagonal channels.
//
// 5. Lateral distribution. This is Key - more difficult than the outer bank erosion. The procedure here is that an edge gradient
// or lateral gradient is calcualted in lateral 2. Then bedload is entrained in erode_w - using Tau calcualted in calc_flow_direction.
// Then in erode_w, a proportion is routed according to bed slope, and a proportion according to the lateral gradient - or the cross
// channel gradient. How strong this cross stream control is is varied by a new variable (cross_channel_gradient) under
// the lateral tab.
//
// 6. There is some other tidying as well, and upadting so most of these variables should be saved/loaded in the xml
// files.
// 4/01/06 v 5.1
// TJC - now can run in reach as well as catchment mode. Allows division of catchment up into subcatchments or reaches with
// both inputs.
// 5.2 - revised lateral erosion routines
// 12/4/2006 v5.3 - adding new veg routines and feedbacks into mannings through vegetation growth
// developed by Jeremy Walsh
using System.IO;
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.Net;
using System.Xml; //JMW
//using System.Threading;
namespace caesar1
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
// private System.Drawing.Bitmap m_objDrawingSurface;
//JMW
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth,
int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwROP);
private System.ComponentModel.IContainer components;
// toms global variables
const Single g = 9.81F;
const Single kappa = 0.4F;
int SW=2;
double water_depth_erosion_threshold=0.01;
int input_time_step=60;
int number_of_points=0;
double globalsediq=0;
double time_1=1;
double save_time=0;
double creep_time=1;
double init_discharge=80;
int tot_number_of_tracer_points=0;
int input_type_flag=0; // 0 is water input from points, 1 is input from hydrograph or rainfall file.
int smoothradius=1;
double failureangle=45;
double saveinterval=1000;
double fexp=2;
int counter=0;
Timer gameClock;
Graphics graphics;
int xmax, ymax;
int init_route_number_of_scans=2;
int maxiterations;
int maxcycle;
const int ACTIVE_FACTOR=1;
const int TRUE=1;
const int FALSE=0;
double ERODEFACTOR=0.05;
double DX=5;
double root=7.07;
double fiveroot=10.04;
int LIMIT=1;
double MIN_Q=0.01;
double CREEP_RATE=0.0025;
double active=0.2;
int G_MAX=10;
int TRACERS=1;
double lateral_constant=0.0000002;
int grain_array_tot=1;
int y_min=2;
double time_factor;
double j=0.000000001; //start of hydrological model paramneters
double jo=0.000000001;
double j_mean;
double old_j_mean=0;
double new_j_mean=0;
double M=0.005;
double K=0.01;
double baseflow=0.00000005; //end of hyd model variables usually 0.0000005 changed 2/11/05
double cycle=0;
double rain_factor=1;
double sediQ=0;
double grow_grass_time=0;
double init_cycle=0;
double output_file_save_interval=60;
double min_time_step=0;
double vegTauCrit=100;
double cross_stream_grad_factor=0;
// grain size variables - the sizes
double d0=10.27; // grass usually 0.27 changed TJ
double d1=0.0005;
double d2=0.001;
double d3=0.002;
double d4=0.004;
double d5=0.008;
double d6=0.016;
double d7=0.032;
double d8=0.064;
double d9=0.128;
double d10=500000; //bedrock (not sure used now..)
// grain size proportions for each fraction... as a proportion of 1.
double d1prop=0.144;
double d2prop=0.022;
double d3prop=0.019;
double d4prop=0.029;
double d5prop=0.068;
double d6prop=0.146;
double d7prop=0.22;
double d8prop=0.231;
double d9prop=0.121;
// Gez
double previous;
int hours = 0;
double new_cycle = 0;
double old_cycle = 0;
double tx = 60;
double Tx = 0;
double tlastcalc = 0;
double Qs_step = 0;
double Qs_hour = 0;
double Qs_over = 0;
double Qs_last = 0;
double Qw_newvol = 0;
double Qw_oldvol = 0;
double Qw_lastvol = 0;
double Qw_stepvol = 0;
double Qw_hourvol = 0;
double Qw_hour = 0;
double Qw_overvol = 0;
double temptotal = 0;
double old_sediq = 0;
double[]sum_grain,old_sum_grain, Qg_step,Qg_hour,Qg_over,Qg_last;
string CATCH_FILE = "catchment.dat";
// end gez
// toms global arrays
double[,] elev,bedrock,init_elevs, discharge,temp_depth,
water_depth,area,dist,tempcreep,water_depth2,lat_vol,Tau, old_water_depth, pool_depth, left_in, left_out, right_in, right_out, up_in, up_out, down_in, down_out;
int[,] index,cross_scan,down_scan,minesites, width, qcounter;
int[,,] flow_dir;
double[,,] max_flow,grain,temp;
double[,,,] strata;
double[] extra_elev,hourly_rain_data, bedrock_depth,temp_grain;
double[,] tracerhydrograph, hydrograph, dischargeinput, tracerinput;
double[,,] inputfile;
int[,] inpoints;
double[,,] veg;
double[,] edge, edge2; //TJC 27/1/05 array for edges
// MJ global vars
double[] fallVelocity;
bool[] isSuspended;
double[,,,] tempsusp,Vsusp;
double[,] tempsusptot,Vsusptot,Csusptot;
int[] deltaX = new int[9] {0,0,1,1,1,0,-1,-1,-1};
int[] deltaY = new int[9] {0,-1,-1,0,1,1,1,0,-1};
int nActualGridCells;
double Jw_newvol = 0.0;
double Jw_oldvol = 0.0;
double Jw_lastvol = 0.0;
double Jw_stepvol = 0.0;
double Jw_hourvol = 0.0;
double Jw_hour = 0.0;
double Jw_overvol = 0.0;
double k_evap = 0.0;
// JOE global vars
double[,,] flow_velocity; //
string[] inputheader; //Read from ASCII DEM
double[,] soil_saturation; //
double[,] slopeAnalysis; // Initially calculated in percent slope, coverted to radians
double[,] aspect; // Radians
double[,] hillshade; // 0 to 255
double hue = 360.0; // Ranges between 0 and 360 degrees
double sat = 0.90; // Ranges between 0 and 1.0 (where 1 is 100%)
double val = 1.0; // Ranges between 0 and 1.0 (where 1 is 100%)
double red = 0.0;
double green = 0.0;
double blue = 0.0;
//JMW Vars
string basetext = "CAESAR - Cellular Automaton Evolutionary Slope And River model.version 5.3beta";
string cfgname = null ; //Config file name
string workdir = "c:\\program files\\Caesar\\work\\";
AviWriter aw; //
private Bitmap bmp; //
private Graphics mygraphics;
//private Boolean DoingGraphics; //
//Form2 form2; //
// JMW end
private System.Windows.Forms.Button button2;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItem13;
private System.Windows.Forms.MenuItem menuItem14;
private System.Windows.Forms.MenuItem menuItem15;
private System.Windows.Forms.MenuItem menuItem16;
private System.Windows.Forms.MenuItem menuItem17;
private System.Windows.Forms.MenuItem menuItem18;
private System.Windows.Forms.MenuItem menuItem19;
private System.Windows.Forms.MenuItem menuItem20;
private System.Windows.Forms.MenuItem menuItem21;
private System.Windows.Forms.MenuItem menuItem22;
private System.Windows.Forms.MenuItem menuItem23;
private System.Windows.Forms.MenuItem menuItem24;
private System.Windows.Forms.MenuItem menuItem25;
private System.Windows.Forms.MenuItem menuItemConfigFile;
private System.Windows.Forms.MenuItem menuItemConfigFileOpen;
private System.Windows.Forms.MenuItem menuItemConfigFileSave;
private System.Windows.Forms.MenuItem menuItemConfigFileSaveAs;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage FilesTab;
private System.Windows.Forms.TabPage GridTab;
private System.Windows.Forms.TabPage NumericalTab;
private System.Windows.Forms.TabPage GrainTab;
private System.Windows.Forms.TabPage HydrologyTab;
private System.Windows.Forms.TextBox gp3box;
private System.Windows.Forms.TextBox gp4box;
private System.Windows.Forms.TextBox gp5box;
private System.Windows.Forms.TextBox gp6box;
private System.Windows.Forms.TextBox gp7box;
private System.Windows.Forms.TextBox gp8box;
private System.Windows.Forms.TextBox gp9box;
private System.Windows.Forms.TextBox gp2box;
private System.Windows.Forms.TextBox gp1box;
private System.Windows.Forms.TextBox g3box;
private System.Windows.Forms.TextBox g4box;
private System.Windows.Forms.TextBox g5box;
private System.Windows.Forms.TextBox g6box;
private System.Windows.Forms.TextBox g7box;
private System.Windows.Forms.TextBox g8box;
private System.Windows.Forms.TextBox g9box;
private System.Windows.Forms.TextBox g2box;
private System.Windows.Forms.TextBox g1box;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.Label label21;
private System.Windows.Forms.Label label20;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.Label label24;
private System.Windows.Forms.Label label39;
private System.Windows.Forms.Label label25;
private System.Windows.Forms.Label label30;
private System.Windows.Forms.CheckBox tracerbox;
private System.Windows.Forms.TextBox openfiletextbox;
private System.Windows.Forms.TextBox graindataloadbox;
private System.Windows.Forms.TextBox bedrockbox;
private System.Windows.Forms.TextBox raindataloadbox;
private System.Windows.Forms.TextBox tracerfile;
private System.Windows.Forms.TextBox tracerhydrofile;
private System.Windows.Forms.Label label32;
private System.Windows.Forms.Label label38;
private System.Windows.Forms.TextBox tracergrainbox;
private System.Windows.Forms.CheckBox checkBoxGenerateAVIFile;
private System.Windows.Forms.TextBox textBoxAVIFile;
private System.Windows.Forms.TextBox input_time_step_box;
private System.Windows.Forms.TextBox infile4;
private System.Windows.Forms.TextBox infile3;
private System.Windows.Forms.TextBox infile2;
private System.Windows.Forms.TextBox infile1;
private System.Windows.Forms.TextBox ybox1;
private System.Windows.Forms.TextBox ybox2;
private System.Windows.Forms.TextBox ybox3;
private System.Windows.Forms.TextBox ybox4;
private System.Windows.Forms.TextBox xbox2;
private System.Windows.Forms.TextBox xbox3;
private System.Windows.Forms.TextBox xbox4;
private System.Windows.Forms.TextBox xbox1;
private System.Windows.Forms.Label label29;
private System.Windows.Forms.Label label44;
private System.Windows.Forms.Label label43;
private System.Windows.Forms.Label label41;
private System.Windows.Forms.CheckBox inbox2;
private System.Windows.Forms.CheckBox inbox3;
private System.Windows.Forms.CheckBox inbox4;
private System.Windows.Forms.CheckBox inbox1;
private System.Windows.Forms.Label label42;
private System.Windows.Forms.TextBox outputfilesaveintervalbox;
private System.Windows.Forms.TextBox saveintervalbox;
private System.Windows.Forms.Label label45;
private System.Windows.Forms.Label label33;
private System.Windows.Forms.CheckBox uniquefilecheck;
private System.Windows.Forms.TabPage DescriptionTab;
private System.Windows.Forms.TextBox DescBox;
private System.Windows.Forms.TextBox ytextbox;
private System.Windows.Forms.TextBox xtextbox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox dxbox;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label50;
private System.Windows.Forms.TextBox activebox;
private System.Windows.Forms.Label label49;
private System.Windows.Forms.TextBox mintimestepbox;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox mvaluebox;
private System.Windows.Forms.TextBox smoothbox;
private System.Windows.Forms.TextBox slopebox;
private System.Windows.Forms.TextBox cyclemaxbox;
private System.Windows.Forms.TextBox itermaxbox;
private System.Windows.Forms.TextBox minqbox;
private System.Windows.Forms.TextBox limitbox;
private System.Windows.Forms.TextBox erodefactorbox;
private System.Windows.Forms.TextBox initscansbox;
private System.Windows.Forms.Label label31;
private System.Windows.Forms.Label label37;
private System.Windows.Forms.Label label35;
private System.Windows.Forms.Label label34;
private System.Windows.Forms.Label label27;
private System.Windows.Forms.Label label26;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox grasstextbox;
private System.Windows.Forms.Label label40;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label48;
private System.Windows.Forms.Label label46;
private System.Windows.Forms.Label label47;
private System.Windows.Forms.Label label51;
private System.Windows.Forms.TextBox creepratebox;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.StatusBarPanel IterationStatusPanel;
private System.Windows.Forms.StatusBarPanel TimeStatusPanel;
private System.Windows.Forms.StatusBarPanel QwStatusPanel;
private System.Windows.Forms.StatusBarPanel QsStatusPanel;
private System.Windows.Forms.StatusBarPanel InfoStatusPanel;
private System.Windows.Forms.StatusBarPanel tempStatusPanel;
private System.Windows.Forms.Button start_button;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox TimeseriesOutBox;
private System.Windows.Forms.TextBox IterationOutbox;
private System.Windows.Forms.CheckBox checkBoxGenerateIterations;
private System.Windows.Forms.CheckBox checkBoxGenerateTimeSeries;
private System.Windows.Forms.MenuItem menuItem26;
private System.Windows.Forms.MenuItem menuItem27;
private System.Windows.Forms.TextBox k_evapBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.MenuItem menuItem28;
private System.Windows.Forms.MenuItem menuItem29;
private System.Windows.Forms.CheckBox suspGS1box;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label28;
private System.Windows.Forms.TextBox fallGS2box;
private System.Windows.Forms.TextBox fallGS1box;
private System.Windows.Forms.CheckBox suspGS2box;
private System.Windows.Forms.CheckBox suspGS3box;
private System.Windows.Forms.CheckBox suspGS4box;
private System.Windows.Forms.CheckBox suspGS5box;
private System.Windows.Forms.CheckBox suspGS6box;
private System.Windows.Forms.CheckBox suspGS7box;
private System.Windows.Forms.CheckBox suspGS8box;
private System.Windows.Forms.CheckBox suspGS9box;
private System.Windows.Forms.Label gpSumLabel;
private System.Windows.Forms.Label gpSumLabel2;
private System.Windows.Forms.TextBox fallGS3box;
private System.Windows.Forms.TextBox fallGS4box;
private System.Windows.Forms.TextBox fallGS5box;
private System.Windows.Forms.TextBox fallGS6box;
private System.Windows.Forms.TextBox fallGS7box;
private System.Windows.Forms.TextBox fallGS8box;
private System.Windows.Forms.TextBox fallGS9box;
private System.Windows.Forms.MenuItem menuItem30;
private System.Windows.Forms.MenuItem menuItem31;
private System.Windows.Forms.MenuItem menuItem32;
private System.Windows.Forms.MenuItem menuItem33;
private System.Windows.Forms.MenuItem menuItem34;
private System.Windows.Forms.CheckBox overrideheaderBox;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TextBox lateralratebox;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.CheckBox oldlateral;
private System.Windows.Forms.CheckBox newlateral;
private System.Windows.Forms.CheckBox catchment_mode_box;
private System.Windows.Forms.CheckBox reach_mode_box;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.CheckBox grassbox;
private System.Windows.Forms.CheckBox recirculatebox;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.Panel Panel1;
private System.Windows.Forms.Label label52;
private System.Windows.Forms.CheckBox bedslope_box;
private System.Windows.Forms.CheckBox wslope_box;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox cross_stream_grad_box;
private System.Windows.Forms.Label label53;
private System.Windows.Forms.Label label54;
private System.Windows.Forms.CheckBox latbox1;
private System.Windows.Forms.CheckBox latbox2;
private System.Windows.Forms.CheckBox latbox3;
private System.Windows.Forms.Label label55;
private System.Windows.Forms.TextBox tempdata1;
private System.Windows.Forms.TextBox tempdata2;
private System.Windows.Forms.TextBox pitdepth;
private System.Windows.Forms.Label label56;
private System.Windows.Forms.CheckBox veltaubox;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TextBox vegTauCritBox;
private System.Windows.Forms.Label label36;
private System.Windows.Forms.TextBox infile5;
private System.Windows.Forms.TextBox ybox5;
private System.Windows.Forms.TextBox xbox5;
private System.Windows.Forms.CheckBox inbox5;
private System.Windows.Forms.TextBox infile6;
private System.Windows.Forms.TextBox ybox6;
private System.Windows.Forms.TextBox xbox6;
private System.Windows.Forms.CheckBox inbox6;
private System.Windows.Forms.TextBox infile7;
private System.Windows.Forms.TextBox ybox7;
private System.Windows.Forms.TextBox xbox7;
private System.Windows.Forms.CheckBox inbox7;
private System.Windows.Forms.TextBox infile8;
private System.Windows.Forms.TextBox ybox8;
private System.Windows.Forms.TextBox xbox8;
private System.Windows.Forms.CheckBox inbox8;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.TextBox propremaining;
private System.Windows.Forms.Label label57;
private System.Windows.Forms.TextBox Q2box;
private Label label58;
double[,] climate_data;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.button2 = new System.Windows.Forms.Button();
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
this.menuItemConfigFile = new System.Windows.Forms.MenuItem();
this.menuItemConfigFileOpen = new System.Windows.Forms.MenuItem();
this.menuItemConfigFileSaveAs = new System.Windows.Forms.MenuItem();
this.menuItemConfigFileSave = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem30 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem26 = new System.Windows.Forms.MenuItem();
this.menuItem27 = new System.Windows.Forms.MenuItem();
this.menuItem28 = new System.Windows.Forms.MenuItem();
this.menuItem31 = new System.Windows.Forms.MenuItem();
this.menuItem32 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.menuItem15 = new System.Windows.Forms.MenuItem();
this.menuItem16 = new System.Windows.Forms.MenuItem();
this.menuItem17 = new System.Windows.Forms.MenuItem();
this.menuItem18 = new System.Windows.Forms.MenuItem();
this.menuItem19 = new System.Windows.Forms.MenuItem();
this.menuItem20 = new System.Windows.Forms.MenuItem();
this.menuItem21 = new System.Windows.Forms.MenuItem();
this.menuItem22 = new System.Windows.Forms.MenuItem();
this.menuItem23 = new System.Windows.Forms.MenuItem();
this.menuItem24 = new System.Windows.Forms.MenuItem();
this.menuItem25 = new System.Windows.Forms.MenuItem();
this.menuItem29 = new System.Windows.Forms.MenuItem();
this.menuItem33 = new System.Windows.Forms.MenuItem();
this.menuItem34 = new System.Windows.Forms.MenuItem();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.FilesTab = new System.Windows.Forms.TabPage();
this.reach_mode_box = new System.Windows.Forms.CheckBox();
this.catchment_mode_box = new System.Windows.Forms.CheckBox();
this.checkBoxGenerateTimeSeries = new System.Windows.Forms.CheckBox();
this.checkBoxGenerateIterations = new System.Windows.Forms.CheckBox();
this.IterationOutbox = new System.Windows.Forms.TextBox();
this.TimeseriesOutBox = new System.Windows.Forms.TextBox();
this.outputfilesaveintervalbox = new System.Windows.Forms.TextBox();
this.saveintervalbox = new System.Windows.Forms.TextBox();
this.label45 = new System.Windows.Forms.Label();
this.label33 = new System.Windows.Forms.Label();
this.uniquefilecheck = new System.Windows.Forms.CheckBox();
this.checkBoxGenerateAVIFile = new System.Windows.Forms.CheckBox();
this.textBoxAVIFile = new System.Windows.Forms.TextBox();
this.tracergrainbox = new System.Windows.Forms.TextBox();
this.label38 = new System.Windows.Forms.Label();
this.label32 = new System.Windows.Forms.Label();
this.tracerhydrofile = new System.Windows.Forms.TextBox();
this.tracerfile = new System.Windows.Forms.TextBox();
this.raindataloadbox = new System.Windows.Forms.TextBox();
this.bedrockbox = new System.Windows.Forms.TextBox();
this.graindataloadbox = new System.Windows.Forms.TextBox();
this.openfiletextbox = new System.Windows.Forms.TextBox();
this.tracerbox = new System.Windows.Forms.CheckBox();
this.label30 = new System.Windows.Forms.Label();
this.label25 = new System.Windows.Forms.Label();
this.label39 = new System.Windows.Forms.Label();
this.label24 = new System.Windows.Forms.Label();
this.label23 = new System.Windows.Forms.Label();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.label56 = new System.Windows.Forms.Label();
this.pitdepth = new System.Windows.Forms.TextBox();
this.label54 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label57 = new System.Windows.Forms.Label();
this.propremaining = new System.Windows.Forms.TextBox();
this.label55 = new System.Windows.Forms.Label();
this.latbox3 = new System.Windows.Forms.CheckBox();
this.latbox2 = new System.Windows.Forms.CheckBox();
this.latbox1 = new System.Windows.Forms.CheckBox();
this.label53 = new System.Windows.Forms.Label();
this.cross_stream_grad_box = new System.Windows.Forms.TextBox();
this.newlateral = new System.Windows.Forms.CheckBox();
this.oldlateral = new System.Windows.Forms.CheckBox();
this.lateralratebox = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.NumericalTab = new System.Windows.Forms.TabPage();
this.label58 = new System.Windows.Forms.Label();
this.Q2box = new System.Windows.Forms.TextBox();
this.veltaubox = new System.Windows.Forms.CheckBox();
this.label52 = new System.Windows.Forms.Label();
this.wslope_box = new System.Windows.Forms.CheckBox();
this.bedslope_box = new System.Windows.Forms.CheckBox();
this.label3 = new System.Windows.Forms.Label();
this.k_evapBox = new System.Windows.Forms.TextBox();
this.label51 = new System.Windows.Forms.Label();
this.label47 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label48 = new System.Windows.Forms.Label();
this.label46 = new System.Windows.Forms.Label();
this.grasstextbox = new System.Windows.Forms.TextBox();
this.label40 = new System.Windows.Forms.Label();
this.label50 = new System.Windows.Forms.Label();
this.activebox = new System.Windows.Forms.TextBox();
this.mintimestepbox = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.mvaluebox = new System.Windows.Forms.TextBox();
this.smoothbox = new System.Windows.Forms.TextBox();
this.slopebox = new System.Windows.Forms.TextBox();
this.cyclemaxbox = new System.Windows.Forms.TextBox();
this.itermaxbox = new System.Windows.Forms.TextBox();
this.creepratebox = new System.Windows.Forms.TextBox();
this.minqbox = new System.Windows.Forms.TextBox();
this.limitbox = new System.Windows.Forms.TextBox();
this.erodefactorbox = new System.Windows.Forms.TextBox();
this.initscansbox = new System.Windows.Forms.TextBox();
this.label31 = new System.Windows.Forms.Label();
this.label37 = new System.Windows.Forms.Label();
this.label35 = new System.Windows.Forms.Label();
this.label34 = new System.Windows.Forms.Label();
this.label27 = new System.Windows.Forms.Label();
this.label26 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label49 = new System.Windows.Forms.Label();
this.GrainTab = new System.Windows.Forms.TabPage();
this.fallGS9box = new System.Windows.Forms.TextBox();
this.fallGS8box = new System.Windows.Forms.TextBox();
this.fallGS7box = new System.Windows.Forms.TextBox();
this.fallGS6box = new System.Windows.Forms.TextBox();
this.fallGS5box = new System.Windows.Forms.TextBox();
this.fallGS4box = new System.Windows.Forms.TextBox();
this.fallGS3box = new System.Windows.Forms.TextBox();
this.gpSumLabel = new System.Windows.Forms.Label();
this.gpSumLabel2 = new System.Windows.Forms.Label();
this.suspGS9box = new System.Windows.Forms.CheckBox();
this.suspGS8box = new System.Windows.Forms.CheckBox();
this.suspGS7box = new System.Windows.Forms.CheckBox();
this.suspGS6box = new System.Windows.Forms.CheckBox();
this.suspGS5box = new System.Windows.Forms.CheckBox();
this.suspGS4box = new System.Windows.Forms.CheckBox();
this.suspGS3box = new System.Windows.Forms.CheckBox();
this.suspGS2box = new System.Windows.Forms.CheckBox();
this.fallGS2box = new System.Windows.Forms.TextBox();
this.fallGS1box = new System.Windows.Forms.TextBox();
this.label28 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.suspGS1box = new System.Windows.Forms.CheckBox();
this.gp3box = new System.Windows.Forms.TextBox();
this.gp4box = new System.Windows.Forms.TextBox();
this.gp5box = new System.Windows.Forms.TextBox();
this.gp6box = new System.Windows.Forms.TextBox();
this.gp7box = new System.Windows.Forms.TextBox();
this.gp8box = new System.Windows.Forms.TextBox();
this.gp9box = new System.Windows.Forms.TextBox();
this.gp2box = new System.Windows.Forms.TextBox();
this.gp1box = new System.Windows.Forms.TextBox();
this.g3box = new System.Windows.Forms.TextBox();
this.g4box = new System.Windows.Forms.TextBox();
this.g5box = new System.Windows.Forms.TextBox();
this.g6box = new System.Windows.Forms.TextBox();
this.g7box = new System.Windows.Forms.TextBox();
this.g8box = new System.Windows.Forms.TextBox();
this.g9box = new System.Windows.Forms.TextBox();
this.g2box = new System.Windows.Forms.TextBox();
this.g1box = new System.Windows.Forms.TextBox();
this.label22 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.label20 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.DescriptionTab = new System.Windows.Forms.TabPage();
this.DescBox = new System.Windows.Forms.TextBox();
this.GridTab = new System.Windows.Forms.TabPage();
this.overrideheaderBox = new System.Windows.Forms.CheckBox();
this.dxbox = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.ytextbox = new System.Windows.Forms.TextBox();
this.xtextbox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.HydrologyTab = new System.Windows.Forms.TabPage();
this.infile8 = new System.Windows.Forms.TextBox();
this.ybox8 = new System.Windows.Forms.TextBox();
this.xbox8 = new System.Windows.Forms.TextBox();
this.inbox8 = new System.Windows.Forms.CheckBox();
this.infile7 = new System.Windows.Forms.TextBox();
this.ybox7 = new System.Windows.Forms.TextBox();
this.xbox7 = new System.Windows.Forms.TextBox();
this.inbox7 = new System.Windows.Forms.CheckBox();
this.infile6 = new System.Windows.Forms.TextBox();
this.ybox6 = new System.Windows.Forms.TextBox();
this.xbox6 = new System.Windows.Forms.TextBox();
this.inbox6 = new System.Windows.Forms.CheckBox();
this.infile5 = new System.Windows.Forms.TextBox();
this.ybox5 = new System.Windows.Forms.TextBox();
this.xbox5 = new System.Windows.Forms.TextBox();
this.inbox5 = new System.Windows.Forms.CheckBox();
this.input_time_step_box = new System.Windows.Forms.TextBox();
this.infile4 = new System.Windows.Forms.TextBox();
this.infile3 = new System.Windows.Forms.TextBox();
this.infile2 = new System.Windows.Forms.TextBox();
this.infile1 = new System.Windows.Forms.TextBox();
this.ybox1 = new System.Windows.Forms.TextBox();
this.ybox2 = new System.Windows.Forms.TextBox();
this.ybox3 = new System.Windows.Forms.TextBox();
this.ybox4 = new System.Windows.Forms.TextBox();
this.xbox2 = new System.Windows.Forms.TextBox();
this.xbox3 = new System.Windows.Forms.TextBox();
this.xbox4 = new System.Windows.Forms.TextBox();
this.xbox1 = new System.Windows.Forms.TextBox();
this.label29 = new System.Windows.Forms.Label();
this.label44 = new System.Windows.Forms.Label();
this.label43 = new System.Windows.Forms.Label();
this.label41 = new System.Windows.Forms.Label();
this.inbox2 = new System.Windows.Forms.CheckBox();
this.inbox3 = new System.Windows.Forms.CheckBox();
this.inbox4 = new System.Windows.Forms.CheckBox();
this.inbox1 = new System.Windows.Forms.CheckBox();
this.label42 = new System.Windows.Forms.Label();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.label36 = new System.Windows.Forms.Label();
this.vegTauCritBox = new System.Windows.Forms.TextBox();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.InfoStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.IterationStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.TimeStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.QwStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.QsStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.tempStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.start_button = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.tempdata1 = new System.Windows.Forms.TextBox();
this.grassbox = new System.Windows.Forms.CheckBox();
this.recirculatebox = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.Panel1 = new System.Windows.Forms.Panel();
this.button5 = new System.Windows.Forms.Button();
this.tempdata2 = new System.Windows.Forms.TextBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.tabControl1.SuspendLayout();
this.FilesTab.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.NumericalTab.SuspendLayout();
this.GrainTab.SuspendLayout();
this.DescriptionTab.SuspendLayout();
this.GridTab.SuspendLayout();
this.HydrologyTab.SuspendLayout();
this.tabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.InfoStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.IterationStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.TimeStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.QwStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.QsStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tempStatusPanel)).BeginInit();
this.Panel1.SuspendLayout();
this.SuspendLayout();
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button2.Location = new System.Drawing.Point(8, 572);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(240, 24);
this.button2.TabIndex = 7;
this.button2.Text = "load data";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemConfigFile,
this.menuItem1,
this.menuItem2,
this.menuItem11});
//
// menuItemConfigFile
//
this.menuItemConfigFile.Index = 0;
this.menuItemConfigFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemConfigFileOpen,
this.menuItemConfigFileSaveAs,
this.menuItemConfigFileSave});
this.menuItemConfigFile.Text = "Config &File";
//
// menuItemConfigFileOpen
//
this.menuItemConfigFileOpen.Index = 0;
this.menuItemConfigFileOpen.Text = "&Open";
this.menuItemConfigFileOpen.Click += new System.EventHandler(this.menuItemConfigFileOpen_Click);
//
// menuItemConfigFileSaveAs
//
this.menuItemConfigFileSaveAs.Index = 1;
this.menuItemConfigFileSaveAs.Text = "Save &As";
this.menuItemConfigFileSaveAs.Click += new System.EventHandler(this.menuItemConfigFileSave_Click);
//
// menuItemConfigFileSave
//
this.menuItemConfigFileSave.Index = 2;
this.menuItemConfigFileSave.Text = "&Save";
this.menuItemConfigFileSave.Click += new System.EventHandler(this.menuItemConfigFileSave_Click);
//
// menuItem1
//
this.menuItem1.Index = 1;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem30,
this.menuItem3,
this.menuItem4,
this.menuItem5,
this.menuItem6});
this.menuItem1.Text = "&Top Graphics";
//
// menuItem30
//
this.menuItem30.Index = 0;
this.menuItem30.Text = "DEM";
this.menuItem30.Click += new System.EventHandler(this.menuItem30_Click);
//
// menuItem3
//
this.menuItem3.Checked = true;
this.menuItem3.Index = 1;
this.menuItem3.Text = "water depth (low scale)";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Index = 2;
this.menuItem4.Text = "erosion/dep";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 3;
this.menuItem5.Text = "Grass/veg cover";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 4;
this.menuItem6.Text = "Mannings value";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem2
//
this.menuItem2.Index = 2;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem7,
this.menuItem8,
this.menuItem9,
this.menuItem10,
this.menuItem26,
this.menuItem27,
this.menuItem28,
this.menuItem31,
this.menuItem32});
this.menuItem2.Text = "&Top graphics II";
//
// menuItem7
//
this.menuItem7.Index = 0;
this.menuItem7.Text = "lateral gradient";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuItem8
//
this.menuItem8.Index = 1;
this.menuItem8.Text = "Bed sheer stress";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// menuItem9
//
this.menuItem9.Index = 2;
this.menuItem9.Text = "grainsize (new scale)";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// menuItem10
//
this.menuItem10.Index = 3;
this.menuItem10.Text = "tracer";
this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
//
// menuItem26
//
this.menuItem26.Index = 4;
this.menuItem26.Text = "Drainage area";
this.menuItem26.Click += new System.EventHandler(this.menuItem26_Click);
//
// menuItem27
//
this.menuItem27.Index = 5;
this.menuItem27.Text = "susp conc";
this.menuItem27.Click += new System.EventHandler(this.menuItem27_Click);
//
// menuItem28
//
this.menuItem28.Index = 6;
this.menuItem28.Text = "susp vol";
this.menuItem28.Click += new System.EventHandler(this.menuItem28_Click);
//
// menuItem31
//
this.menuItem31.Index = 7;
this.menuItem31.Text = "flow velocity";
this.menuItem31.Click += new System.EventHandler(this.menuItem31_Click);
//
// menuItem32
//
this.menuItem32.Index = 8;
this.menuItem32.Text = "soil saturation";
this.menuItem32.Click += new System.EventHandler(this.menuItem32_Click);
//
// menuItem11
//
this.menuItem11.Index = 3;
this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem12,
this.menuItem13,
this.menuItem14,
this.menuItem15,
this.menuItem16,
this.menuItem17,
this.menuItem18,
this.menuItem19,
this.menuItem20,
this.menuItem21,
this.menuItem22,
this.menuItem23,
this.menuItem24,
this.menuItem25,
this.menuItem29,
this.menuItem33,
this.menuItem34});
this.menuItem11.Text = "Save Options";
//
// menuItem12
//
this.menuItem12.Checked = true;
this.menuItem12.Index = 0;
this.menuItem12.Text = "elevations";
this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
//
// menuItem13
//
this.menuItem13.Checked = true;
this.menuItem13.Index = 1;
this.menuItem13.Text = "elev diff";
this.menuItem13.Click += new System.EventHandler(this.menuItem13_Click);
//
// menuItem14
//
this.menuItem14.Checked = true;
this.menuItem14.Index = 2;
this.menuItem14.Text = "grainsize";
this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click);
//
// menuItem15
//
this.menuItem15.Checked = true;
this.menuItem15.Index = 3;
this.menuItem15.Text = "total tracer g/s";
this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click);
//
// menuItem16
//
this.menuItem16.Index = 4;
this.menuItem16.Text = "tracer layer1";
this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
//
// menuItem17
//
this.menuItem17.Index = 5;
this.menuItem17.Text = "tracer layer2";
this.menuItem17.Click += new System.EventHandler(this.menuItem17_Click);
//
// menuItem18
//
this.menuItem18.Index = 6;
this.menuItem18.Text = "tracer layer3";
this.menuItem18.Click += new System.EventHandler(this.menuItem18_Click);
//
// menuItem19
//
this.menuItem19.Index = 7;
this.menuItem19.Text = "tracer layer4";
this.menuItem19.Click += new System.EventHandler(this.menuItem19_Click);
//
// menuItem20
//
this.menuItem20.Index = 8;
this.menuItem20.Text = "tracer layer5";
this.menuItem20.Click += new System.EventHandler(this.menuItem20_Click);
//
// menuItem21
//
this.menuItem21.Index = 9;
this.menuItem21.Text = "tracer layer6";
this.menuItem21.Click += new System.EventHandler(this.menuItem21_Click);
//
// menuItem22
//
this.menuItem22.Index = 10;
this.menuItem22.Text = "tracer layer7";
this.menuItem22.Click += new System.EventHandler(this.menuItem22_Click);
//
// menuItem23
//
this.menuItem23.Index = 11;
this.menuItem23.Text = "tracer layer8";
this.menuItem23.Click += new System.EventHandler(this.menuItem23_Click);
//
// menuItem24
//
this.menuItem24.Index = 12;
this.menuItem24.Text = "tracer layer9";
this.menuItem24.Click += new System.EventHandler(this.menuItem24_Click);
//
// menuItem25
//
this.menuItem25.Index = 13;
this.menuItem25.Text = "water depth";
this.menuItem25.Click += new System.EventHandler(this.menuItem25_Click);
//
// menuItem29
//
this.menuItem29.Checked = true;
this.menuItem29.Index = 14;
this.menuItem29.Text = "d50 top layer";
this.menuItem29.Click += new System.EventHandler(this.menuItem29_Click);
//
// menuItem33
//
this.menuItem33.Index = 15;
this.menuItem33.Text = "flow velocity";
this.menuItem33.Click += new System.EventHandler(this.menuItem33_Click);
//
// menuItem34
//
this.menuItem34.Index = 16;
this.menuItem34.Text = "soil saturation";
this.menuItem34.Click += new System.EventHandler(this.menuItem34_Click);
//
// tabControl1
//
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.FilesTab);
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.NumericalTab);
this.tabControl1.Controls.Add(this.GrainTab);
this.tabControl1.Controls.Add(this.DescriptionTab);
this.tabControl1.Controls.Add(this.GridTab);
this.tabControl1.Controls.Add(this.HydrologyTab);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Location = new System.Drawing.Point(7, 7);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(933, 556);
this.tabControl1.TabIndex = 143;
//
// FilesTab
//
this.FilesTab.Controls.Add(this.reach_mode_box);
this.FilesTab.Controls.Add(this.catchment_mode_box);
this.FilesTab.Controls.Add(this.checkBoxGenerateTimeSeries);
this.FilesTab.Controls.Add(this.checkBoxGenerateIterations);
this.FilesTab.Controls.Add(this.IterationOutbox);
this.FilesTab.Controls.Add(this.TimeseriesOutBox);
this.FilesTab.Controls.Add(this.outputfilesaveintervalbox);
this.FilesTab.Controls.Add(this.saveintervalbox);
this.FilesTab.Controls.Add(this.label45);
this.FilesTab.Controls.Add(this.label33);
this.FilesTab.Controls.Add(this.uniquefilecheck);
this.FilesTab.Controls.Add(this.checkBoxGenerateAVIFile);
this.FilesTab.Controls.Add(this.textBoxAVIFile);
this.FilesTab.Controls.Add(this.tracergrainbox);
this.FilesTab.Controls.Add(this.label38);
this.FilesTab.Controls.Add(this.label32);
this.FilesTab.Controls.Add(this.tracerhydrofile);
this.FilesTab.Controls.Add(this.tracerfile);
this.FilesTab.Controls.Add(this.raindataloadbox);
this.FilesTab.Controls.Add(this.bedrockbox);
this.FilesTab.Controls.Add(this.graindataloadbox);
this.FilesTab.Controls.Add(this.openfiletextbox);
this.FilesTab.Controls.Add(this.tracerbox);
this.FilesTab.Controls.Add(this.label30);
this.FilesTab.Controls.Add(this.label25);
this.FilesTab.Controls.Add(this.label39);
this.FilesTab.Controls.Add(this.label24);
this.FilesTab.Controls.Add(this.label23);
this.FilesTab.Location = new System.Drawing.Point(4, 22);
this.FilesTab.Name = "FilesTab";
this.FilesTab.Size = new System.Drawing.Size(925, 530);
this.FilesTab.TabIndex = 0;
this.FilesTab.Text = "Files";
//
// reach_mode_box
//
this.reach_mode_box.Checked = true;
this.reach_mode_box.CheckState = System.Windows.Forms.CheckState.Checked;
this.reach_mode_box.Location = new System.Drawing.Point(340, 62);
this.reach_mode_box.Name = "reach_mode_box";
this.reach_mode_box.Size = new System.Drawing.Size(147, 42);
this.reach_mode_box.TabIndex = 175;
this.reach_mode_box.Text = "Reach Mode";
this.toolTip1.SetToolTip(this.reach_mode_box, "CAESAR can run in both catchment and reach mode combined. But if you have reach m" +
"ode selected, you should enter an input file in the hydrology tab");
//
// catchment_mode_box
//
this.catchment_mode_box.Location = new System.Drawing.Point(340, 42);
this.catchment_mode_box.Name = "catchment_mode_box";
this.catchment_mode_box.Size = new System.Drawing.Size(147, 34);
this.catchment_mode_box.TabIndex = 174;
this.catchment_mode_box.Text = "Catchment mode";
this.toolTip1.SetToolTip(this.catchment_mode_box, "CAESAR can run in both catchment and reach mode, but if you have catchment mode c" +
"hecked, you should input a rainfall data file");
this.catchment_mode_box.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// checkBoxGenerateTimeSeries
//
this.checkBoxGenerateTimeSeries.Checked = true;
this.checkBoxGenerateTimeSeries.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBoxGenerateTimeSeries.Location = new System.Drawing.Point(20, 312);
this.checkBoxGenerateTimeSeries.Name = "checkBoxGenerateTimeSeries";
this.checkBoxGenerateTimeSeries.Size = new System.Drawing.Size(160, 24);
this.checkBoxGenerateTimeSeries.TabIndex = 173;
this.checkBoxGenerateTimeSeries.Text = "Generate time series output";
//
// checkBoxGenerateIterations
//
this.checkBoxGenerateIterations.Location = new System.Drawing.Point(20, 361);
this.checkBoxGenerateIterations.Name = "checkBoxGenerateIterations";
this.checkBoxGenerateIterations.Size = new System.Drawing.Size(152, 24);
this.checkBoxGenerateIterations.TabIndex = 172;
this.checkBoxGenerateIterations.Text = "Generate iteration output";
//
// IterationOutbox
//
this.IterationOutbox.Location = new System.Drawing.Point(180, 361);
this.IterationOutbox.Name = "IterationOutbox";
this.IterationOutbox.Size = new System.Drawing.Size(112, 20);
this.IterationOutbox.TabIndex = 170;
this.IterationOutbox.Text = "iterout.dat";
//
// TimeseriesOutBox
//
this.TimeseriesOutBox.Location = new System.Drawing.Point(184, 312);
this.TimeseriesOutBox.Name = "TimeseriesOutBox";
this.TimeseriesOutBox.Size = new System.Drawing.Size(112, 20);
this.TimeseriesOutBox.TabIndex = 168;
this.TimeseriesOutBox.Text = "catchment.dat";
//
// outputfilesaveintervalbox
//
this.outputfilesaveintervalbox.Location = new System.Drawing.Point(184, 336);
this.outputfilesaveintervalbox.Name = "outputfilesaveintervalbox";
this.outputfilesaveintervalbox.Size = new System.Drawing.Size(56, 20);
this.outputfilesaveintervalbox.TabIndex = 166;
this.outputfilesaveintervalbox.Text = "60";
//
// saveintervalbox
//
this.saveintervalbox.Location = new System.Drawing.Point(184, 284);
this.saveintervalbox.Name = "saveintervalbox";
this.saveintervalbox.Size = new System.Drawing.Size(56, 20);
this.saveintervalbox.TabIndex = 163;
this.saveintervalbox.Text = "1000";
//
// label45
//
this.label45.Location = new System.Drawing.Point(24, 336);
this.label45.Name = "label45";
this.label45.Size = new System.Drawing.Size(152, 24);
this.label45.TabIndex = 167;
this.label45.Text = "Save file every * mins";
this.label45.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label33
//
this.label33.Location = new System.Drawing.Point(24, 284);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(152, 25);
this.label33.TabIndex = 165;
this.label33.Text = "Save file every * mins";
this.label33.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.toolTip1.SetToolTip(this.label33, "How often the avi file AND the other data files are saved");
//
// uniquefilecheck
//
this.uniquefilecheck.Location = new System.Drawing.Point(248, 284);
this.uniquefilecheck.Name = "uniquefilecheck";
this.uniquefilecheck.Size = new System.Drawing.Size(120, 25);
this.uniquefilecheck.TabIndex = 164;
this.uniquefilecheck.Text = "unique file name?";
this.toolTip1.SetToolTip(this.uniquefilecheck, "Whether the data files are given a unqiu file name - ");
//
// checkBoxGenerateAVIFile
//
this.checkBoxGenerateAVIFile.Location = new System.Drawing.Point(20, 257);
this.checkBoxGenerateAVIFile.Name = "checkBoxGenerateAVIFile";
this.checkBoxGenerateAVIFile.Size = new System.Drawing.Size(128, 24);
this.checkBoxGenerateAVIFile.TabIndex = 162;
this.checkBoxGenerateAVIFile.Text = "Generate Avi File";
this.toolTip1.SetToolTip(this.checkBoxGenerateAVIFile, "Check to generate a movie file of the screen display");
//
// textBoxAVIFile
//
this.textBoxAVIFile.Location = new System.Drawing.Point(184, 257);
this.textBoxAVIFile.Name = "textBoxAVIFile";
this.textBoxAVIFile.Size = new System.Drawing.Size(112, 20);
this.textBoxAVIFile.TabIndex = 161;
this.textBoxAVIFile.Text = "out.avi";
this.toolTip1.SetToolTip(this.textBoxAVIFile, "File name for avi file");
//
// tracergrainbox
//
this.tracergrainbox.Location = new System.Drawing.Point(152, 200);
this.tracergrainbox.Name = "tracergrainbox";
this.tracergrainbox.Size = new System.Drawing.Size(120, 20);
this.tracergrainbox.TabIndex = 108;
this.tracergrainbox.Text = "null";
//
// label38
//
this.label38.Location = new System.Drawing.Point(16, 200);
this.label38.Name = "label38";
this.label38.Size = new System.Drawing.Size(128, 24);
this.label38.TabIndex = 107;
this.label38.Text = "tracer grainsize data file";
this.label38.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label32
//
this.label32.Location = new System.Drawing.Point(16, 176);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(128, 24);
this.label32.TabIndex = 106;
this.label32.Text = "tracer sediment vol file";
this.label32.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// tracerhydrofile
//
this.tracerhydrofile.Location = new System.Drawing.Point(152, 176);
this.tracerhydrofile.Name = "tracerhydrofile";
this.tracerhydrofile.Size = new System.Drawing.Size(120, 20);
this.tracerhydrofile.TabIndex = 105;
this.tracerhydrofile.Text = "null";
//
// tracerfile
//
this.tracerfile.Location = new System.Drawing.Point(152, 152);
this.tracerfile.Name = "tracerfile";
this.tracerfile.Size = new System.Drawing.Size(120, 20);
this.tracerfile.TabIndex = 104;
this.tracerfile.Text = "null";
//
// raindataloadbox
//
this.raindataloadbox.Location = new System.Drawing.Point(128, 96);
this.raindataloadbox.Name = "raindataloadbox";
this.raindataloadbox.Size = new System.Drawing.Size(120, 20);
this.raindataloadbox.TabIndex = 103;
this.raindataloadbox.Text = "null";
//
// bedrockbox
//
this.bedrockbox.Location = new System.Drawing.Point(128, 72);
this.bedrockbox.Name = "bedrockbox";
this.bedrockbox.Size = new System.Drawing.Size(120, 20);
this.bedrockbox.TabIndex = 102;
this.bedrockbox.Text = "null";
//
// graindataloadbox
//
this.graindataloadbox.Location = new System.Drawing.Point(128, 48);
this.graindataloadbox.Name = "graindataloadbox";
this.graindataloadbox.Size = new System.Drawing.Size(120, 20);
this.graindataloadbox.TabIndex = 101;
this.graindataloadbox.Text = "null";
//
// openfiletextbox
//
this.openfiletextbox.Location = new System.Drawing.Point(128, 24);
this.openfiletextbox.Name = "openfiletextbox";
this.openfiletextbox.Size = new System.Drawing.Size(120, 20);
this.openfiletextbox.TabIndex = 100;
this.openfiletextbox.Text = "whole9.dat";
//
// tracerbox
//
this.tracerbox.Location = new System.Drawing.Point(27, 132);
this.tracerbox.Name = "tracerbox";
this.tracerbox.Size = new System.Drawing.Size(88, 23);
this.tracerbox.TabIndex = 99;
this.tracerbox.Text = "tracer run?";
this.toolTip1.SetToolTip(this.tracerbox, "Check to run in \'tracer mode\'");
//
// label30
//
this.label30.Location = new System.Drawing.Point(16, 152);
this.label30.Name = "label30";
this.label30.Size = new System.Drawing.Size(128, 24);
this.label30.TabIndex = 98;
this.label30.Text = "tracer input file";
this.label30.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label25
//
this.label25.Location = new System.Drawing.Point(16, 96);
this.label25.Name = "label25";
this.label25.Size = new System.Drawing.Size(104, 24);
this.label25.TabIndex = 97;
this.label25.Text = "Rainfall data file";
this.label25.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.toolTip1.SetToolTip(this.label25, "Hourly rainfall data - in an ascii format");
//
// label39
//
this.label39.Location = new System.Drawing.Point(16, 72);
this.label39.Name = "label39";
this.label39.Size = new System.Drawing.Size(104, 24);
this.label39.TabIndex = 96;
this.label39.Text = "Bedrock data file";
this.label39.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.toolTip1.SetToolTip(this.label39, "A DEM of the bedrock - below which the model cannot erode");
//
// label24
//
this.label24.Location = new System.Drawing.Point(16, 48);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(104, 24);
this.label24.TabIndex = 58;
this.label24.Text = "Grain data file";
this.label24.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label23
//
this.label23.Location = new System.Drawing.Point(16, 24);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(104, 24);
this.label23.TabIndex = 56;
this.label23.Text = "DEM data file";
this.label23.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.label56);
this.tabPage1.Controls.Add(this.pitdepth);
this.tabPage1.Controls.Add(this.label54);
this.tabPage1.Controls.Add(this.groupBox1);
this.tabPage1.Controls.Add(this.newlateral);
this.tabPage1.Controls.Add(this.oldlateral);
this.tabPage1.Controls.Add(this.lateralratebox);
this.tabPage1.Controls.Add(this.label7);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(925, 530);
this.tabPage1.TabIndex = 6;
this.tabPage1.Text = "lateral erosion";
//
// label56
//
this.label56.Location = new System.Drawing.Point(80, 395);
this.label56.Name = "label56";
this.label56.Size = new System.Drawing.Size(107, 28);
this.label56.TabIndex = 157;
this.label56.Text = "Pit depth";
//
// pitdepth
//
this.pitdepth.Location = new System.Drawing.Point(27, 395);
this.pitdepth.Name = "pitdepth";
this.pitdepth.Size = new System.Drawing.Size(46, 20);
this.pitdepth.TabIndex = 156;
this.pitdepth.Text = "20";
//
// label54
//
this.label54.Location = new System.Drawing.Point(340, 28);
this.label54.Name = "label54";
this.label54.Size = new System.Drawing.Size(400, 388);
this.label54.TabIndex = 155;
this.label54.Text = resources.GetString("label54.Text");
this.label54.Click += new System.EventHandler(this.label54_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label57);
this.groupBox1.Controls.Add(this.propremaining);
this.groupBox1.Controls.Add(this.label55);
this.groupBox1.Controls.Add(this.latbox3);
this.groupBox1.Controls.Add(this.latbox2);
this.groupBox1.Controls.Add(this.latbox1);
this.groupBox1.Controls.Add(this.label53);
this.groupBox1.Controls.Add(this.cross_stream_grad_box);
this.groupBox1.Location = new System.Drawing.Point(27, 90);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(286, 291);
this.groupBox1.TabIndex = 154;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Parameters for lateral method 2";
//
// label57
//
this.label57.Location = new System.Drawing.Point(87, 257);
this.label57.Name = "label57";
this.label57.Size = new System.Drawing.Size(186, 27);
this.label57.TabIndex = 7;
this.label57.Text = "Proportion remaining after lat erosion";
//
// propremaining
//
this.propremaining.Location = new System.Drawing.Point(7, 257);
this.propremaining.Name = "propremaining";
this.propremaining.Size = new System.Drawing.Size(73, 20);
this.propremaining.TabIndex = 6;
this.propremaining.Text = "1.0";
//
// label55
//
this.label55.Location = new System.Drawing.Point(7, 42);
this.label55.Name = "label55";
this.label55.Size = new System.Drawing.Size(260, 62);
this.label55.TabIndex = 5;
this.label55.Text = "Lateral erosion rules (below). Rc=Radius of curvature/Channel width; Wd = water d" +
"epth (near bank); T = Tau (near bank); t = time step; Lc = lateral constant; E =" +
" erosion rate (near bank)";
//
// latbox3
//
this.latbox3.Location = new System.Drawing.Point(7, 159);
this.latbox3.Name = "latbox3";
this.latbox3.Size = new System.Drawing.Size(260, 28);
this.latbox3.TabIndex = 4;
this.latbox3.Text = "rule 3 = Rc Wd E Lc";
//
// latbox2
//
this.latbox2.Location = new System.Drawing.Point(7, 132);
this.latbox2.Name = "latbox2";
this.latbox2.Size = new System.Drawing.Size(260, 27);
this.latbox2.TabIndex = 3;
this.latbox2.Text = "rule 2 = Rc Wd E t Lc";
//
// latbox1
//
this.latbox1.Checked = true;
this.latbox1.CheckState = System.Windows.Forms.CheckState.Checked;
this.latbox1.Location = new System.Drawing.Point(7, 104);
this.latbox1.Name = "latbox1";
this.latbox1.Size = new System.Drawing.Size(260, 28);
this.latbox1.TabIndex = 2;
this.latbox1.Text = "rule 1 = Rc Wd T t Lc";
//
// label53
//
this.label53.Location = new System.Drawing.Point(113, 21);
this.label53.Name = "label53";
this.label53.Size = new System.Drawing.Size(160, 21);
this.label53.TabIndex = 1;
this.label53.Text = "Cross stream gradient factor";
this.toolTip1.SetToolTip(this.label53, "This factor determines how great the cross stream gradient determined by radius o" +
"f curvature is in relation to bed slope");
//
// cross_stream_grad_box
//
this.cross_stream_grad_box.Location = new System.Drawing.Point(13, 21);
this.cross_stream_grad_box.Name = "cross_stream_grad_box";
this.cross_stream_grad_box.Size = new System.Drawing.Size(87, 20);
this.cross_stream_grad_box.TabIndex = 0;
this.cross_stream_grad_box.Text = "2";
//
// newlateral
//
this.newlateral.Location = new System.Drawing.Point(27, 62);
this.newlateral.Name = "newlateral";
this.newlateral.Size = new System.Drawing.Size(106, 28);
this.newlateral.TabIndex = 153;
this.newlateral.Text = "Lateral method 2";
this.newlateral.CheckedChanged += new System.EventHandler(this.newlateral_CheckedChanged);
//
// oldlateral
//
this.oldlateral.Checked = true;
this.oldlateral.CheckState = System.Windows.Forms.CheckState.Checked;
this.oldlateral.Location = new System.Drawing.Point(27, 35);
this.oldlateral.Name = "oldlateral";
this.oldlateral.Size = new System.Drawing.Size(106, 20);
this.oldlateral.TabIndex = 152;
this.oldlateral.Text = "Lateral method 1";
this.oldlateral.CheckedChanged += new System.EventHandler(this.oldlateral_CheckedChanged);
//
// lateralratebox
//
this.lateralratebox.Location = new System.Drawing.Point(260, 35);
this.lateralratebox.Name = "lateralratebox";
this.lateralratebox.Size = new System.Drawing.Size(64, 20);
this.lateralratebox.TabIndex = 150;
this.lateralratebox.Text = "0.000000";
//
// label7
//
this.label7.Location = new System.Drawing.Point(147, 35);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(95, 24);
this.label7.TabIndex = 151;
this.label7.Text = "Lat erosion rate";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.toolTip1.SetToolTip(this.label7, "Lateral erosion constant that is applied to method 1 (old laterla) and method 2 (" +
"new lateral)");
//
// NumericalTab
//
this.NumericalTab.Controls.Add(this.label58);
this.NumericalTab.Controls.Add(this.Q2box);
this.NumericalTab.Controls.Add(this.veltaubox);
this.NumericalTab.Controls.Add(this.label52);
this.NumericalTab.Controls.Add(this.wslope_box);
this.NumericalTab.Controls.Add(this.bedslope_box);
this.NumericalTab.Controls.Add(this.label3);
this.NumericalTab.Controls.Add(this.k_evapBox);
this.NumericalTab.Controls.Add(this.label51);
this.NumericalTab.Controls.Add(this.label47);
this.NumericalTab.Controls.Add(this.textBox3);
this.NumericalTab.Controls.Add(this.textBox2);
this.NumericalTab.Controls.Add(this.label48);
this.NumericalTab.Controls.Add(this.label46);
this.NumericalTab.Controls.Add(this.grasstextbox);
this.NumericalTab.Controls.Add(this.label40);
this.NumericalTab.Controls.Add(this.label50);
this.NumericalTab.Controls.Add(this.activebox);
this.NumericalTab.Controls.Add(this.mintimestepbox);
this.NumericalTab.Controls.Add(this.textBox1);
this.NumericalTab.Controls.Add(this.mvaluebox);
this.NumericalTab.Controls.Add(this.smoothbox);
this.NumericalTab.Controls.Add(this.slopebox);
this.NumericalTab.Controls.Add(this.cyclemaxbox);
this.NumericalTab.Controls.Add(this.itermaxbox);
this.NumericalTab.Controls.Add(this.creepratebox);
this.NumericalTab.Controls.Add(this.minqbox);
this.NumericalTab.Controls.Add(this.limitbox);
this.NumericalTab.Controls.Add(this.erodefactorbox);
this.NumericalTab.Controls.Add(this.initscansbox);
this.NumericalTab.Controls.Add(this.label31);
this.NumericalTab.Controls.Add(this.label37);
this.NumericalTab.Controls.Add(this.label35);
this.NumericalTab.Controls.Add(this.label34);
this.NumericalTab.Controls.Add(this.label27);
this.NumericalTab.Controls.Add(this.label26);
this.NumericalTab.Controls.Add(this.label12);
this.NumericalTab.Controls.Add(this.label10);
this.NumericalTab.Controls.Add(this.label9);
this.NumericalTab.Controls.Add(this.label8);
this.NumericalTab.Controls.Add(this.label5);
this.NumericalTab.Controls.Add(this.label49);
this.NumericalTab.Location = new System.Drawing.Point(4, 22);
this.NumericalTab.Name = "NumericalTab";
this.NumericalTab.Size = new System.Drawing.Size(925, 530);
this.NumericalTab.TabIndex = 2;
this.NumericalTab.Text = "Numerical";
//
// label58
//
this.label58.AutoSize = true;
this.label58.Location = new System.Drawing.Point(302, 184);
this.label58.Name = "label58";
this.label58.Size = new System.Drawing.Size(157, 13);
this.label58.TabIndex = 185;
this.label58.Text = "max that surface flow will route..";
//
// Q2box
//
this.Q2box.Location = new System.Drawing.Point(247, 180);
this.Q2box.Name = "Q2box";
this.Q2box.Size = new System.Drawing.Size(49, 20);
this.Q2box.TabIndex = 184;
this.Q2box.Text = "0.01";
//
// veltaubox
//
this.veltaubox.Location = new System.Drawing.Point(427, 153);
this.veltaubox.Name = "veltaubox";
this.veltaubox.Size = new System.Drawing.Size(160, 27);
this.veltaubox.TabIndex = 183;
this.veltaubox.Text = "Tau based on velocity";
this.veltaubox.CheckedChanged += new System.EventHandler(this.veltaubox_CheckedChanged);
//
// label52
//
this.label52.Location = new System.Drawing.Point(427, 83);
this.label52.Name = "label52";
this.label52.Size = new System.Drawing.Size(133, 28);
this.label52.TabIndex = 182;
this.label52.Text = "Slope used to calc Tau (for erosion)";
this.toolTip1.SetToolTip(this.label52, "See notes on lateral tab for more. ");
//
// wslope_box
//
this.wslope_box.Location = new System.Drawing.Point(427, 132);
this.wslope_box.Name = "wslope_box";
this.wslope_box.Size = new System.Drawing.Size(160, 21);
this.wslope_box.TabIndex = 181;
this.wslope_box.Text = "Water surface slope";
this.wslope_box.CheckedChanged += new System.EventHandler(this.wslope_box_CheckedChanged);
//
// bedslope_box
//
this.bedslope_box.Checked = true;
this.bedslope_box.CheckState = System.Windows.Forms.CheckState.Checked;
this.bedslope_box.Location = new System.Drawing.Point(427, 104);
this.bedslope_box.Name = "bedslope_box";
this.bedslope_box.Size = new System.Drawing.Size(153, 35);
this.bedslope_box.TabIndex = 180;
this.bedslope_box.Text = "Bedslope";
this.bedslope_box.CheckedChanged += new System.EventHandler(this.bedslope_box_CheckedChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(48, 416);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(128, 24);
this.label3.TabIndex = 179;
this.label3.Text = "Evaporation rate (m/s)";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// k_evapBox
//
this.k_evapBox.Location = new System.Drawing.Point(184, 416);
this.k_evapBox.Name = "k_evapBox";
this.k_evapBox.Size = new System.Drawing.Size(80, 20);
this.k_evapBox.TabIndex = 178;
this.k_evapBox.Text = "0.0";
//
// label51
//
this.label51.Location = new System.Drawing.Point(232, 392);
this.label51.Name = "label51";
this.label51.Size = new System.Drawing.Size(100, 23);
this.label51.TabIndex = 177;
this.label51.Text = "(reach mode)";
this.label51.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label47
//
this.label47.Location = new System.Drawing.Point(256, 88);
this.label47.Name = "label47";
this.label47.Size = new System.Drawing.Size(100, 23);
this.label47.TabIndex = 176;
this.label47.Text = "(caution !)";
this.label47.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(184, 368);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(40, 20);
this.textBox3.TabIndex = 174;
this.textBox3.Text = "2";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(184, 392);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(40, 20);
this.textBox2.TabIndex = 172;
this.textBox2.Text = "60";
//
// label48
//
this.label48.Location = new System.Drawing.Point(24, 368);
this.label48.Name = "label48";
this.label48.Size = new System.Drawing.Size(152, 24);
this.label48.TabIndex = 175;
this.label48.Text = "flow distribution width (cells)";
this.label48.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label46
//
this.label46.Location = new System.Drawing.Point(48, 392);
this.label46.Name = "label46";
this.label46.Size = new System.Drawing.Size(128, 24);
this.label46.TabIndex = 173;
this.label46.Text = "Initial discharge (m3/s)";
this.label46.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// grasstextbox
//
this.grasstextbox.Location = new System.Drawing.Point(184, 344);
this.grasstextbox.Name = "grasstextbox";
this.grasstextbox.Size = new System.Drawing.Size(40, 20);
this.grasstextbox.TabIndex = 170;
this.grasstextbox.Text = "5";
//
// label40
//
this.label40.Location = new System.Drawing.Point(56, 344);
this.label40.Name = "label40";
this.label40.Size = new System.Drawing.Size(120, 24);
this.label40.TabIndex = 171;
this.label40.Text = "Grass maturity (yrs)";
this.label40.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label50
//
this.label50.Location = new System.Drawing.Point(40, 248);
this.label50.Name = "label50";
this.label50.Size = new System.Drawing.Size(136, 24);
this.label50.TabIndex = 169;
this.label50.Text = "active layer thickness (m)";
this.label50.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// activebox
//
this.activebox.Location = new System.Drawing.Point(184, 248);
this.activebox.Name = "activebox";
this.activebox.Size = new System.Drawing.Size(64, 20);
this.activebox.TabIndex = 168;
this.activebox.Text = "0.2";
//
// mintimestepbox
//
this.mintimestepbox.Location = new System.Drawing.Point(184, 88);
this.mintimestepbox.Name = "mintimestepbox";
this.mintimestepbox.Size = new System.Drawing.Size(64, 20);
this.mintimestepbox.TabIndex = 166;
this.mintimestepbox.Text = "0";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(184, 112);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(64, 20);
this.textBox1.TabIndex = 164;
this.textBox1.Text = "0";
//
// mvaluebox
//
this.mvaluebox.Location = new System.Drawing.Point(184, 320);
this.mvaluebox.Name = "mvaluebox";
this.mvaluebox.Size = new System.Drawing.Size(40, 20);
this.mvaluebox.TabIndex = 162;
this.mvaluebox.Text = "0.01";
//
// smoothbox
//
this.smoothbox.Location = new System.Drawing.Point(184, 296);
this.smoothbox.Name = "smoothbox";
this.smoothbox.Size = new System.Drawing.Size(40, 20);
this.smoothbox.TabIndex = 160;
this.smoothbox.Text = "1";
//
// slopebox
//
this.slopebox.Location = new System.Drawing.Point(184, 272);
this.slopebox.Name = "slopebox";
this.slopebox.Size = new System.Drawing.Size(40, 20);
this.slopebox.TabIndex = 158;
this.slopebox.Text = "45";
//
// cyclemaxbox
//
this.cyclemaxbox.Location = new System.Drawing.Point(184, 136);
this.cyclemaxbox.Name = "cyclemaxbox";
this.cyclemaxbox.Size = new System.Drawing.Size(64, 20);
this.cyclemaxbox.TabIndex = 155;
this.cyclemaxbox.Text = "1000";
//
// itermaxbox
//
this.itermaxbox.Location = new System.Drawing.Point(184, 56);
this.itermaxbox.Name = "itermaxbox";
this.itermaxbox.Size = new System.Drawing.Size(64, 20);
this.itermaxbox.TabIndex = 154;
this.itermaxbox.Text = "100000";
//
// creepratebox
//
this.creepratebox.Location = new System.Drawing.Point(184, 200);
this.creepratebox.Name = "creepratebox";
this.creepratebox.Size = new System.Drawing.Size(49, 20);
this.creepratebox.TabIndex = 146;
this.creepratebox.Text = "0.0025";
//
// minqbox
//
this.minqbox.Location = new System.Drawing.Point(184, 176);
this.minqbox.Name = "minqbox";
this.minqbox.Size = new System.Drawing.Size(49, 20);
this.minqbox.TabIndex = 145;
this.minqbox.Text = "0.01";
//
// limitbox
//
this.limitbox.Location = new System.Drawing.Point(184, 16);
this.limitbox.Name = "limitbox";
this.limitbox.Size = new System.Drawing.Size(40, 20);
this.limitbox.TabIndex = 144;
this.limitbox.Text = "1";
//
// erodefactorbox
//
this.erodefactorbox.Location = new System.Drawing.Point(528, 48);
this.erodefactorbox.Name = "erodefactorbox";
this.erodefactorbox.Size = new System.Drawing.Size(40, 20);
this.erodefactorbox.TabIndex = 143;
this.erodefactorbox.Text = "0.02";
//
// initscansbox
//
this.initscansbox.Location = new System.Drawing.Point(528, 24);
this.initscansbox.Name = "initscansbox";
this.initscansbox.Size = new System.Drawing.Size(40, 20);
this.initscansbox.TabIndex = 142;
this.initscansbox.Text = "20";
//
// label31
//
this.label31.Location = new System.Drawing.Point(56, 112);
this.label31.Name = "label31";
this.label31.Size = new System.Drawing.Size(120, 24);
this.label31.TabIndex = 165;
this.label31.Text = "run start time (h)";
this.label31.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label37
//
this.label37.Location = new System.Drawing.Point(48, 320);
this.label37.Name = "label37";
this.label37.Size = new System.Drawing.Size(128, 24);
this.label37.TabIndex = 163;
this.label37.Text = "\'m\' value";
this.label37.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label35
//
this.label35.Location = new System.Drawing.Point(56, 296);
this.label35.Name = "label35";
this.label35.Size = new System.Drawing.Size(120, 24);
this.label35.TabIndex = 161;
this.label35.Text = "WS smoothing radius";
this.label35.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label34
//
this.label34.Location = new System.Drawing.Point(48, 272);
this.label34.Name = "label34";
this.label34.Size = new System.Drawing.Size(128, 24);
this.label34.TabIndex = 159;
this.label34.Text = "slope failure threshold";
this.label34.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label27
//
this.label27.Location = new System.Drawing.Point(64, 136);
this.label27.Name = "label27";
this.label27.Size = new System.Drawing.Size(112, 24);
this.label27.TabIndex = 157;
this.label27.Text = "max run duration (h)";
this.label27.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label26
//
this.label26.Location = new System.Drawing.Point(40, 56);
this.label26.Name = "label26";
this.label26.Size = new System.Drawing.Size(136, 24);
this.label26.TabIndex = 156;
this.label26.Text = "max # of iterations";
this.label26.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label12
//
this.label12.Location = new System.Drawing.Point(433, 48);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(87, 24);
this.label12.TabIndex = 153;
this.label12.Text = "Max erode limit";
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label10
//
this.label10.Location = new System.Drawing.Point(56, 16);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(120, 24);
this.label10.TabIndex = 152;
this.label10.Text = "memory limit";
this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label9
//
this.label9.Location = new System.Drawing.Point(56, 176);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(120, 24);
this.label9.TabIndex = 151;
this.label9.Text = "Min Q for depth calc";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.toolTip1.SetToolTip(this.label9, "MinQ is a threshold value, above which CAEASR treats flow as surface flow, it sho" +
"uld be scaled to the grid size. Try 0.01 for 10m grids and 0.25 for 50m..");
//
// label8
//
this.label8.Location = new System.Drawing.Point(80, 200);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(96, 24);
this.label8.TabIndex = 150;
this.label8.Text = "Creep rate";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label5
//
this.label5.Location = new System.Drawing.Point(440, 24);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(73, 26);
this.label5.TabIndex = 148;
this.label5.Text = "init # of scans";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label49
//
this.label49.Location = new System.Drawing.Point(40, 88);
this.label49.Name = "label49";
this.label49.Size = new System.Drawing.Size(136, 24);
this.label49.TabIndex = 167;
this.label49.Text = "Min time step (s)";
this.label49.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// GrainTab
//
this.GrainTab.Controls.Add(this.fallGS9box);
this.GrainTab.Controls.Add(this.fallGS8box);
this.GrainTab.Controls.Add(this.fallGS7box);
this.GrainTab.Controls.Add(this.fallGS6box);
this.GrainTab.Controls.Add(this.fallGS5box);
this.GrainTab.Controls.Add(this.fallGS4box);
this.GrainTab.Controls.Add(this.fallGS3box);
this.GrainTab.Controls.Add(this.gpSumLabel);
this.GrainTab.Controls.Add(this.gpSumLabel2);
this.GrainTab.Controls.Add(this.suspGS9box);
this.GrainTab.Controls.Add(this.suspGS8box);
this.GrainTab.Controls.Add(this.suspGS7box);
this.GrainTab.Controls.Add(this.suspGS6box);
this.GrainTab.Controls.Add(this.suspGS5box);
this.GrainTab.Controls.Add(this.suspGS4box);
this.GrainTab.Controls.Add(this.suspGS3box);
this.GrainTab.Controls.Add(this.suspGS2box);
this.GrainTab.Controls.Add(this.fallGS2box);
this.GrainTab.Controls.Add(this.fallGS1box);
this.GrainTab.Controls.Add(this.label28);
this.GrainTab.Controls.Add(this.label4);
this.GrainTab.Controls.Add(this.suspGS1box);
this.GrainTab.Controls.Add(this.gp3box);
this.GrainTab.Controls.Add(this.gp4box);
this.GrainTab.Controls.Add(this.gp5box);
this.GrainTab.Controls.Add(this.gp6box);
this.GrainTab.Controls.Add(this.gp7box);
this.GrainTab.Controls.Add(this.gp8box);
this.GrainTab.Controls.Add(this.gp9box);
this.GrainTab.Controls.Add(this.gp2box);
this.GrainTab.Controls.Add(this.gp1box);
this.GrainTab.Controls.Add(this.g3box);
this.GrainTab.Controls.Add(this.g4box);
this.GrainTab.Controls.Add(this.g5box);
this.GrainTab.Controls.Add(this.g6box);
this.GrainTab.Controls.Add(this.g7box);
this.GrainTab.Controls.Add(this.g8box);
this.GrainTab.Controls.Add(this.g9box);
this.GrainTab.Controls.Add(this.g2box);
this.GrainTab.Controls.Add(this.g1box);
this.GrainTab.Controls.Add(this.label22);
this.GrainTab.Controls.Add(this.label21);
this.GrainTab.Controls.Add(this.label20);
this.GrainTab.Controls.Add(this.label19);
this.GrainTab.Controls.Add(this.label18);
this.GrainTab.Controls.Add(this.label17);
this.GrainTab.Controls.Add(this.label16);
this.GrainTab.Controls.Add(this.label15);
this.GrainTab.Controls.Add(this.label14);
this.GrainTab.Controls.Add(this.label13);
this.GrainTab.Controls.Add(this.label6);
this.GrainTab.Location = new System.Drawing.Point(4, 22);
this.GrainTab.Name = "GrainTab";
this.GrainTab.Size = new System.Drawing.Size(925, 530);
this.GrainTab.TabIndex = 3;
this.GrainTab.Text = "Sediment";
//
// fallGS9box
//
this.fallGS9box.Enabled = false;
this.fallGS9box.Location = new System.Drawing.Point(424, 296);
this.fallGS9box.Name = "fallGS9box";
this.fallGS9box.Size = new System.Drawing.Size(100, 20);
this.fallGS9box.TabIndex = 90;
this.fallGS9box.Text = "1.357";
//
// fallGS8box
//
this.fallGS8box.Enabled = false;
this.fallGS8box.Location = new System.Drawing.Point(424, 264);
this.fallGS8box.Name = "fallGS8box";
this.fallGS8box.Size = new System.Drawing.Size(100, 20);
this.fallGS8box.TabIndex = 89;
this.fallGS8box.Text = "0.959";
//
// fallGS7box
//
this.fallGS7box.Enabled = false;
this.fallGS7box.Location = new System.Drawing.Point(424, 232);
this.fallGS7box.Name = "fallGS7box";
this.fallGS7box.Size = new System.Drawing.Size(100, 20);
this.fallGS7box.TabIndex = 88;
this.fallGS7box.Text = "0.678";
//
// fallGS6box
//
this.fallGS6box.Enabled = false;
this.fallGS6box.Location = new System.Drawing.Point(424, 200);
this.fallGS6box.Name = "fallGS6box";
this.fallGS6box.Size = new System.Drawing.Size(100, 20);
this.fallGS6box.TabIndex = 87;
this.fallGS6box.Text = "0.479";
//
// fallGS5box
//
this.fallGS5box.Enabled = false;
this.fallGS5box.Location = new System.Drawing.Point(424, 168);
this.fallGS5box.Name = "fallGS5box";
this.fallGS5box.Size = new System.Drawing.Size(100, 20);
this.fallGS5box.TabIndex = 86;
this.fallGS5box.Text = "0.338";
//
// fallGS4box
//
this.fallGS4box.Enabled = false;
this.fallGS4box.Location = new System.Drawing.Point(424, 136);
this.fallGS4box.Name = "fallGS4box";
this.fallGS4box.Size = new System.Drawing.Size(100, 20);
this.fallGS4box.TabIndex = 85;
this.fallGS4box.Text = "0.237";
//
// fallGS3box
//
this.fallGS3box.Enabled = false;
this.fallGS3box.Location = new System.Drawing.Point(424, 104);
this.fallGS3box.Name = "fallGS3box";
this.fallGS3box.Size = new System.Drawing.Size(100, 20);
this.fallGS3box.TabIndex = 84;
this.fallGS3box.Text = "0.164";
//
// gpSumLabel
//
this.gpSumLabel.Location = new System.Drawing.Point(232, 360);
this.gpSumLabel.Name = "gpSumLabel";
this.gpSumLabel.Size = new System.Drawing.Size(96, 16);
this.gpSumLabel.TabIndex = 105;
this.gpSumLabel.Text = "OK";
this.gpSumLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// gpSumLabel2
//
this.gpSumLabel2.ForeColor = System.Drawing.SystemColors.ControlText;
this.gpSumLabel2.Location = new System.Drawing.Point(232, 336);
this.gpSumLabel2.Name = "gpSumLabel2";
this.gpSumLabel2.Size = new System.Drawing.Size(112, 16);
this.gpSumLabel2.TabIndex = 104;
this.gpSumLabel2.Text = "sum must equal 1.0";
this.gpSumLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// suspGS9box
//
this.suspGS9box.Location = new System.Drawing.Point(376, 296);
this.suspGS9box.Name = "suspGS9box";
this.suspGS9box.Size = new System.Drawing.Size(16, 24);
this.suspGS9box.TabIndex = 81;
this.suspGS9box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// suspGS8box
//
this.suspGS8box.Location = new System.Drawing.Point(376, 264);
this.suspGS8box.Name = "suspGS8box";
this.suspGS8box.Size = new System.Drawing.Size(16, 24);
this.suspGS8box.TabIndex = 80;
this.suspGS8box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// suspGS7box
//
this.suspGS7box.Location = new System.Drawing.Point(376, 232);
this.suspGS7box.Name = "suspGS7box";
this.suspGS7box.Size = new System.Drawing.Size(16, 24);
this.suspGS7box.TabIndex = 79;
this.suspGS7box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// suspGS6box
//
this.suspGS6box.Location = new System.Drawing.Point(376, 200);
this.suspGS6box.Name = "suspGS6box";
this.suspGS6box.Size = new System.Drawing.Size(16, 24);
this.suspGS6box.TabIndex = 78;
this.suspGS6box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// suspGS5box
//
this.suspGS5box.Location = new System.Drawing.Point(376, 168);
this.suspGS5box.Name = "suspGS5box";
this.suspGS5box.Size = new System.Drawing.Size(16, 24);
this.suspGS5box.TabIndex = 77;
this.suspGS5box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// suspGS4box
//
this.suspGS4box.Location = new System.Drawing.Point(376, 136);
this.suspGS4box.Name = "suspGS4box";
this.suspGS4box.Size = new System.Drawing.Size(16, 24);
this.suspGS4box.TabIndex = 76;
this.suspGS4box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// suspGS3box
//
this.suspGS3box.Location = new System.Drawing.Point(376, 104);
this.suspGS3box.Name = "suspGS3box";
this.suspGS3box.Size = new System.Drawing.Size(16, 24);
this.suspGS3box.TabIndex = 75;
this.suspGS3box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// suspGS2box
//
this.suspGS2box.Checked = true;
this.suspGS2box.CheckState = System.Windows.Forms.CheckState.Checked;
this.suspGS2box.Location = new System.Drawing.Point(376, 72);
this.suspGS2box.Name = "suspGS2box";
this.suspGS2box.Size = new System.Drawing.Size(16, 24);
this.suspGS2box.TabIndex = 74;
this.suspGS2box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// fallGS2box
//
this.fallGS2box.Location = new System.Drawing.Point(424, 72);
this.fallGS2box.Name = "fallGS2box";
this.fallGS2box.Size = new System.Drawing.Size(100, 20);
this.fallGS2box.TabIndex = 83;
this.fallGS2box.Text = "0.109";
//
// fallGS1box
//
this.fallGS1box.Location = new System.Drawing.Point(424, 40);
this.fallGS1box.Name = "fallGS1box";
this.fallGS1box.Size = new System.Drawing.Size(100, 20);
this.fallGS1box.TabIndex = 82;
this.fallGS1box.Text = "0.066";
//
// label28
//
this.label28.Location = new System.Drawing.Point(432, 16);
this.label28.Name = "label28";
this.label28.Size = new System.Drawing.Size(88, 16);
this.label28.TabIndex = 95;
this.label28.Text = "fall velocity (m/s)";
this.label28.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.Location = new System.Drawing.Point(336, 16);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(96, 16);
this.label4.TabIndex = 85;
this.label4.Text = "suspended ?";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// suspGS1box
//
this.suspGS1box.Checked = true;
this.suspGS1box.CheckState = System.Windows.Forms.CheckState.Checked;
this.suspGS1box.Location = new System.Drawing.Point(376, 40);
this.suspGS1box.Name = "suspGS1box";
this.suspGS1box.Size = new System.Drawing.Size(16, 24);
this.suspGS1box.TabIndex = 73;
this.suspGS1box.CheckedChanged += new System.EventHandler(this.suspCheckedChange);
//
// gp3box
//
this.gp3box.Location = new System.Drawing.Point(232, 104);
this.gp3box.Name = "gp3box";
this.gp3box.Size = new System.Drawing.Size(100, 20);
this.gp3box.TabIndex = 66;
this.gp3box.Text = "0.019";
this.gp3box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// gp4box
//
this.gp4box.Location = new System.Drawing.Point(232, 136);
this.gp4box.Name = "gp4box";
this.gp4box.Size = new System.Drawing.Size(100, 20);
this.gp4box.TabIndex = 67;
this.gp4box.Text = "0.029";
this.gp4box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// gp5box
//
this.gp5box.Location = new System.Drawing.Point(232, 168);
this.gp5box.Name = "gp5box";
this.gp5box.Size = new System.Drawing.Size(100, 20);
this.gp5box.TabIndex = 68;
this.gp5box.Text = "0.068";
this.gp5box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// gp6box
//
this.gp6box.Location = new System.Drawing.Point(232, 200);
this.gp6box.Name = "gp6box";
this.gp6box.Size = new System.Drawing.Size(100, 20);
this.gp6box.TabIndex = 69;
this.gp6box.Text = "0.146";
this.gp6box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// gp7box
//
this.gp7box.Location = new System.Drawing.Point(232, 232);
this.gp7box.Name = "gp7box";
this.gp7box.Size = new System.Drawing.Size(100, 20);
this.gp7box.TabIndex = 70;
this.gp7box.Text = "0.220";
this.gp7box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// gp8box
//
this.gp8box.Location = new System.Drawing.Point(232, 264);
this.gp8box.Name = "gp8box";
this.gp8box.Size = new System.Drawing.Size(100, 20);
this.gp8box.TabIndex = 71;
this.gp8box.Text = "0.231";
this.gp8box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// gp9box
//
this.gp9box.Location = new System.Drawing.Point(232, 296);
this.gp9box.Name = "gp9box";
this.gp9box.Size = new System.Drawing.Size(100, 20);
this.gp9box.TabIndex = 72;
this.gp9box.Text = "0.121";
this.gp9box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// gp2box
//
this.gp2box.Location = new System.Drawing.Point(232, 72);
this.gp2box.Name = "gp2box";
this.gp2box.Size = new System.Drawing.Size(100, 20);
this.gp2box.TabIndex = 65;
this.gp2box.Text = "0.022";
this.gp2box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// gp1box
//
this.gp1box.Location = new System.Drawing.Point(232, 40);
this.gp1box.Name = "gp1box";
this.gp1box.Size = new System.Drawing.Size(100, 20);
this.gp1box.TabIndex = 64;
this.gp1box.Text = "0.144";
this.gp1box.TextChanged += new System.EventHandler(this.fracGSchanged);
//
// g3box
//
this.g3box.Location = new System.Drawing.Point(96, 104);
this.g3box.Name = "g3box";
this.g3box.Size = new System.Drawing.Size(100, 20);
this.g3box.TabIndex = 57;
this.g3box.Text = "0.002";
//
// g4box
//
this.g4box.Location = new System.Drawing.Point(96, 136);
this.g4box.Name = "g4box";
this.g4box.Size = new System.Drawing.Size(100, 20);
this.g4box.TabIndex = 58;
this.g4box.Text = "0.004";
//
// g5box
//
this.g5box.Location = new System.Drawing.Point(96, 168);
this.g5box.Name = "g5box";
this.g5box.Size = new System.Drawing.Size(100, 20);
this.g5box.TabIndex = 59;
this.g5box.Text = "0.008";
//
// g6box
//
this.g6box.Location = new System.Drawing.Point(96, 200);
this.g6box.Name = "g6box";
this.g6box.Size = new System.Drawing.Size(100, 20);
this.g6box.TabIndex = 60;
this.g6box.Text = "0.016";
//
// g7box
//
this.g7box.Location = new System.Drawing.Point(96, 232);
this.g7box.Name = "g7box";
this.g7box.Size = new System.Drawing.Size(100, 20);
this.g7box.TabIndex = 61;
this.g7box.Text = "0.032";
//
// g8box
//
this.g8box.Location = new System.Drawing.Point(96, 264);
this.g8box.Name = "g8box";
this.g8box.Size = new System.Drawing.Size(100, 20);
this.g8box.TabIndex = 62;
this.g8box.Text = "0.064";
//
// g9box
//
this.g9box.Location = new System.Drawing.Point(96, 296);
this.g9box.Name = "g9box";
this.g9box.Size = new System.Drawing.Size(100, 20);
this.g9box.TabIndex = 63;
this.g9box.Text = "0.128";
//
// g2box
//
this.g2box.Location = new System.Drawing.Point(96, 72);
this.g2box.Name = "g2box";
this.g2box.Size = new System.Drawing.Size(100, 20);
this.g2box.TabIndex = 56;
this.g2box.Text = "0.001";
//
// g1box
//
this.g1box.Location = new System.Drawing.Point(96, 40);
this.g1box.Name = "g1box";
this.g1box.Size = new System.Drawing.Size(100, 20);
this.g1box.TabIndex = 55;
this.g1box.Text = "0.0005";
//
// label22
//
this.label22.Location = new System.Drawing.Point(232, 16);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(96, 16);
this.label22.TabIndex = 83;
this.label22.Text = "proportion";
this.label22.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label21
//
this.label21.Location = new System.Drawing.Point(96, 16);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(96, 16);
this.label21.TabIndex = 82;
this.label21.Text = "grain size (m)";
this.label21.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label20
//
this.label20.Location = new System.Drawing.Point(24, 72);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(40, 24);
this.label20.TabIndex = 81;
this.label20.Text = "size2";
this.label20.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label19
//
this.label19.Location = new System.Drawing.Point(24, 104);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(40, 24);
this.label19.TabIndex = 80;
this.label19.Text = "size3";
this.label19.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label18
//
this.label18.Location = new System.Drawing.Point(24, 136);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(40, 24);
this.label18.TabIndex = 79;
this.label18.Text = "size4";
this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label17
//
this.label17.Location = new System.Drawing.Point(24, 168);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(40, 24);
this.label17.TabIndex = 78;
this.label17.Text = "size5";
this.label17.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label16
//
this.label16.Location = new System.Drawing.Point(24, 200);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(40, 24);
this.label16.TabIndex = 77;
this.label16.Text = "size6";
this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label15
//
this.label15.Location = new System.Drawing.Point(24, 232);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(40, 24);
this.label15.TabIndex = 76;
this.label15.Text = "size7";
this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label14
//
this.label14.Location = new System.Drawing.Point(24, 264);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(40, 24);
this.label14.TabIndex = 75;
this.label14.Text = "size8";
this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label13
//
this.label13.Location = new System.Drawing.Point(24, 296);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(40, 24);
this.label13.TabIndex = 74;
this.label13.Text = "size9";
this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label6
//
this.label6.Location = new System.Drawing.Point(24, 40);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(40, 24);
this.label6.TabIndex = 73;
this.label6.Text = "size1";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// DescriptionTab
//
this.DescriptionTab.Controls.Add(this.DescBox);
this.DescriptionTab.Location = new System.Drawing.Point(4, 22);
this.DescriptionTab.Name = "DescriptionTab";
this.DescriptionTab.Size = new System.Drawing.Size(925, 530);
this.DescriptionTab.TabIndex = 5;
this.DescriptionTab.Text = "Description";
//
// DescBox
//
this.DescBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.DescBox.Location = new System.Drawing.Point(16, 16);
this.DescBox.Multiline = true;
this.DescBox.Name = "DescBox";
this.DescBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.DescBox.Size = new System.Drawing.Size(894, 500);
this.DescBox.TabIndex = 132;
//
// GridTab
//
this.GridTab.Controls.Add(this.overrideheaderBox);
this.GridTab.Controls.Add(this.dxbox);
this.GridTab.Controls.Add(this.label11);
this.GridTab.Controls.Add(this.ytextbox);
this.GridTab.Controls.Add(this.xtextbox);
this.GridTab.Controls.Add(this.label2);
this.GridTab.Controls.Add(this.label1);
this.GridTab.Location = new System.Drawing.Point(4, 22);
this.GridTab.Name = "GridTab";
this.GridTab.Size = new System.Drawing.Size(925, 530);
this.GridTab.TabIndex = 1;
this.GridTab.Text = "Grid";
//
// overrideheaderBox
//
this.overrideheaderBox.Location = new System.Drawing.Point(16, 16);
this.overrideheaderBox.Name = "overrideheaderBox";
this.overrideheaderBox.Size = new System.Drawing.Size(200, 24);
this.overrideheaderBox.TabIndex = 27;
this.overrideheaderBox.Text = "override header file";
this.overrideheaderBox.CheckedChanged += new System.EventHandler(this.overrideheaderBox_CheckedChanged);
//
// dxbox
//
this.dxbox.Enabled = false;
this.dxbox.Location = new System.Drawing.Point(120, 88);
this.dxbox.Name = "dxbox";
this.dxbox.Size = new System.Drawing.Size(40, 20);
this.dxbox.TabIndex = 25;
this.dxbox.Text = "5";
//
// label11
//
this.label11.Enabled = false;
this.label11.Location = new System.Drawing.Point(16, 88);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(96, 24);
this.label11.TabIndex = 26;
this.label11.Text = "Cell size";
this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ytextbox
//
this.ytextbox.Enabled = false;
this.ytextbox.Location = new System.Drawing.Point(120, 64);
this.ytextbox.Name = "ytextbox";
this.ytextbox.Size = new System.Drawing.Size(56, 20);
this.ytextbox.TabIndex = 5;
this.ytextbox.Text = "358";
//
// xtextbox
//
this.xtextbox.Enabled = false;
this.xtextbox.Location = new System.Drawing.Point(120, 40);
this.xtextbox.Name = "xtextbox";
this.xtextbox.Size = new System.Drawing.Size(56, 20);
this.xtextbox.TabIndex = 4;
this.xtextbox.Text = "593";
//
// label2
//
this.label2.Enabled = false;
this.label2.Location = new System.Drawing.Point(16, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(96, 24);
this.label2.TabIndex = 7;
this.label2.Text = "Y coordinates";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label1
//
this.label1.Enabled = false;
this.label1.Location = new System.Drawing.Point(24, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 24);
this.label1.TabIndex = 6;
this.label1.Text = "X coordinates";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// HydrologyTab
//
this.HydrologyTab.Controls.Add(this.infile8);
this.HydrologyTab.Controls.Add(this.ybox8);
this.HydrologyTab.Controls.Add(this.xbox8);
this.HydrologyTab.Controls.Add(this.inbox8);
this.HydrologyTab.Controls.Add(this.infile7);
this.HydrologyTab.Controls.Add(this.ybox7);
this.HydrologyTab.Controls.Add(this.xbox7);
this.HydrologyTab.Controls.Add(this.inbox7);
this.HydrologyTab.Controls.Add(this.infile6);
this.HydrologyTab.Controls.Add(this.ybox6);
this.HydrologyTab.Controls.Add(this.xbox6);
this.HydrologyTab.Controls.Add(this.inbox6);
this.HydrologyTab.Controls.Add(this.infile5);
this.HydrologyTab.Controls.Add(this.ybox5);
this.HydrologyTab.Controls.Add(this.xbox5);
this.HydrologyTab.Controls.Add(this.inbox5);
this.HydrologyTab.Controls.Add(this.input_time_step_box);
this.HydrologyTab.Controls.Add(this.infile4);
this.HydrologyTab.Controls.Add(this.infile3);
this.HydrologyTab.Controls.Add(this.infile2);
this.HydrologyTab.Controls.Add(this.infile1);
this.HydrologyTab.Controls.Add(this.ybox1);
this.HydrologyTab.Controls.Add(this.ybox2);
this.HydrologyTab.Controls.Add(this.ybox3);
this.HydrologyTab.Controls.Add(this.ybox4);
this.HydrologyTab.Controls.Add(this.xbox2);
this.HydrologyTab.Controls.Add(this.xbox3);
this.HydrologyTab.Controls.Add(this.xbox4);
this.HydrologyTab.Controls.Add(this.xbox1);
this.HydrologyTab.Controls.Add(this.label29);
this.HydrologyTab.Controls.Add(this.label44);
this.HydrologyTab.Controls.Add(this.label43);
this.HydrologyTab.Controls.Add(this.label41);
this.HydrologyTab.Controls.Add(this.inbox2);
this.HydrologyTab.Controls.Add(this.inbox3);
this.HydrologyTab.Controls.Add(this.inbox4);
this.HydrologyTab.Controls.Add(this.inbox1);
this.HydrologyTab.Controls.Add(this.label42);
this.HydrologyTab.Location = new System.Drawing.Point(4, 22);
this.HydrologyTab.Name = "HydrologyTab";
this.HydrologyTab.Size = new System.Drawing.Size(925, 530);
this.HydrologyTab.TabIndex = 4;
this.HydrologyTab.Text = "Hydrology";
//
// infile8
//
this.infile8.Location = new System.Drawing.Point(173, 229);
this.infile8.Name = "infile8";
this.infile8.Size = new System.Drawing.Size(120, 20);
this.infile8.TabIndex = 198;
//
// ybox8
//
this.ybox8.Location = new System.Drawing.Point(127, 229);
this.ybox8.Name = "ybox8";
this.ybox8.Size = new System.Drawing.Size(31, 20);
this.ybox8.TabIndex = 197;
//
// xbox8
//
this.xbox8.Location = new System.Drawing.Point(80, 229);
this.xbox8.Name = "xbox8";
this.xbox8.Size = new System.Drawing.Size(32, 20);
this.xbox8.TabIndex = 196;
//
// inbox8
//
this.inbox8.Location = new System.Drawing.Point(13, 229);
this.inbox8.Name = "inbox8";
this.inbox8.Size = new System.Drawing.Size(64, 16);
this.inbox8.TabIndex = 195;
this.inbox8.Text = "Input 8";
//
// infile7
//
this.infile7.Location = new System.Drawing.Point(173, 201);
this.infile7.Name = "infile7";
this.infile7.Size = new System.Drawing.Size(120, 20);
this.infile7.TabIndex = 194;
//
// ybox7
//
this.ybox7.Location = new System.Drawing.Point(127, 201);
this.ybox7.Name = "ybox7";
this.ybox7.Size = new System.Drawing.Size(31, 20);
this.ybox7.TabIndex = 193;
//
// xbox7
//
this.xbox7.Location = new System.Drawing.Point(80, 201);
this.xbox7.Name = "xbox7";
this.xbox7.Size = new System.Drawing.Size(32, 20);
this.xbox7.TabIndex = 192;
//
// inbox7
//
this.inbox7.Location = new System.Drawing.Point(13, 201);
this.inbox7.Name = "inbox7";
this.inbox7.Size = new System.Drawing.Size(64, 17);
this.inbox7.TabIndex = 191;
this.inbox7.Text = "Input 7";
//
// infile6
//
this.infile6.Location = new System.Drawing.Point(173, 173);
this.infile6.Name = "infile6";
this.infile6.Size = new System.Drawing.Size(120, 20);
this.infile6.TabIndex = 190;
//
// ybox6
//
this.ybox6.Location = new System.Drawing.Point(127, 173);
this.ybox6.Name = "ybox6";
this.ybox6.Size = new System.Drawing.Size(31, 20);
this.ybox6.TabIndex = 189;
//
// xbox6
//
this.xbox6.Location = new System.Drawing.Point(80, 173);
this.xbox6.Name = "xbox6";
this.xbox6.Size = new System.Drawing.Size(32, 20);
this.xbox6.TabIndex = 188;
//
// inbox6
//
this.inbox6.Location = new System.Drawing.Point(13, 173);
this.inbox6.Name = "inbox6";
this.inbox6.Size = new System.Drawing.Size(64, 17);
this.inbox6.TabIndex = 187;
this.inbox6.Text = "Input 6";
//
// infile5
//
this.infile5.Location = new System.Drawing.Point(173, 146);
this.infile5.Name = "infile5";
this.infile5.Size = new System.Drawing.Size(120, 20);
this.infile5.TabIndex = 186;
//
// ybox5
//
this.ybox5.Location = new System.Drawing.Point(127, 146);
this.ybox5.Name = "ybox5";
this.ybox5.Size = new System.Drawing.Size(31, 20);
this.ybox5.TabIndex = 185;
//
// xbox5
//
this.xbox5.Location = new System.Drawing.Point(80, 146);
this.xbox5.Name = "xbox5";
this.xbox5.Size = new System.Drawing.Size(32, 20);
this.xbox5.TabIndex = 184;
//
// inbox5
//
this.inbox5.Location = new System.Drawing.Point(13, 146);
this.inbox5.Name = "inbox5";
this.inbox5.Size = new System.Drawing.Size(64, 16);
this.inbox5.TabIndex = 183;
this.inbox5.Text = "Input 5";
//
// input_time_step_box
//
this.input_time_step_box.Location = new System.Drawing.Point(327, 83);
this.input_time_step_box.Name = "input_time_step_box";
this.input_time_step_box.Size = new System.Drawing.Size(63, 20);
this.input_time_step_box.TabIndex = 181;
this.input_time_step_box.Text = "1440";
//
// infile4
//
this.infile4.Location = new System.Drawing.Point(176, 120);
this.infile4.Name = "infile4";
this.infile4.Size = new System.Drawing.Size(120, 20);
this.infile4.TabIndex = 180;
//
// infile3
//
this.infile3.Location = new System.Drawing.Point(176, 96);
this.infile3.Name = "infile3";
this.infile3.Size = new System.Drawing.Size(120, 20);
this.infile3.TabIndex = 179;
//
// infile2
//
this.infile2.Location = new System.Drawing.Point(176, 72);
this.infile2.Name = "infile2";
this.infile2.Size = new System.Drawing.Size(120, 20);
this.infile2.TabIndex = 178;
//
// infile1
//
this.infile1.Location = new System.Drawing.Point(176, 48);
this.infile1.Name = "infile1";
this.infile1.Size = new System.Drawing.Size(120, 20);
this.infile1.TabIndex = 177;
//
// ybox1
//
this.ybox1.Location = new System.Drawing.Point(128, 48);
this.ybox1.Name = "ybox1";
this.ybox1.Size = new System.Drawing.Size(32, 20);
this.ybox1.TabIndex = 175;
//
// ybox2
//
this.ybox2.Location = new System.Drawing.Point(128, 72);
this.ybox2.Name = "ybox2";
this.ybox2.Size = new System.Drawing.Size(32, 20);
this.ybox2.TabIndex = 174;
//
// ybox3
//
this.ybox3.Location = new System.Drawing.Point(128, 96);
this.ybox3.Name = "ybox3";
this.ybox3.Size = new System.Drawing.Size(32, 20);
this.ybox3.TabIndex = 173;
//
// ybox4
//
this.ybox4.Location = new System.Drawing.Point(128, 120);
this.ybox4.Name = "ybox4";
this.ybox4.Size = new System.Drawing.Size(32, 20);
this.ybox4.TabIndex = 172;
//
// xbox2
//
this.xbox2.Location = new System.Drawing.Point(80, 72);
this.xbox2.Name = "xbox2";
this.xbox2.Size = new System.Drawing.Size(32, 20);
this.xbox2.TabIndex = 171;
//
// xbox3
//
this.xbox3.Location = new System.Drawing.Point(80, 96);
this.xbox3.Name = "xbox3";
this.xbox3.Size = new System.Drawing.Size(32, 20);
this.xbox3.TabIndex = 170;
//
// xbox4
//
this.xbox4.Location = new System.Drawing.Point(80, 120);
this.xbox4.Name = "xbox4";
this.xbox4.Size = new System.Drawing.Size(32, 20);
this.xbox4.TabIndex = 169;
//
// xbox1
//
this.xbox1.Location = new System.Drawing.Point(80, 48);
this.xbox1.Name = "xbox1";
this.xbox1.Size = new System.Drawing.Size(32, 20);
this.xbox1.TabIndex = 168;
//
// label29
//
this.label29.Location = new System.Drawing.Point(400, 76);
this.label29.Name = "label29";
this.label29.Size = new System.Drawing.Size(100, 32);
this.label29.TabIndex = 182;
this.label29.Text = "input data time step (mins)";
//
// label44
//
this.label44.Location = new System.Drawing.Point(176, 24);
this.label44.Name = "label44";
this.label44.Size = new System.Drawing.Size(56, 16);
this.label44.TabIndex = 176;
this.label44.Text = "File Name";
//
// label43
//
this.label43.Location = new System.Drawing.Point(136, 24);
this.label43.Name = "label43";
this.label43.Size = new System.Drawing.Size(16, 16);
this.label43.TabIndex = 167;
this.label43.Text = "Y";
//
// label41
//
this.label41.Location = new System.Drawing.Point(88, 24);
this.label41.Name = "label41";
this.label41.Size = new System.Drawing.Size(16, 16);
this.label41.TabIndex = 165;
this.label41.Text = "X";
//
// inbox2
//
this.inbox2.Location = new System.Drawing.Point(16, 72);
this.inbox2.Name = "inbox2";
this.inbox2.Size = new System.Drawing.Size(64, 16);
this.inbox2.TabIndex = 164;
this.inbox2.Text = "Input 2";
//
// inbox3
//
this.inbox3.Location = new System.Drawing.Point(16, 96);
this.inbox3.Name = "inbox3";
this.inbox3.Size = new System.Drawing.Size(64, 16);
this.inbox3.TabIndex = 163;
this.inbox3.Text = "Input 3";
//
// inbox4
//
this.inbox4.Location = new System.Drawing.Point(16, 120);
this.inbox4.Name = "inbox4";
this.inbox4.Size = new System.Drawing.Size(64, 16);
this.inbox4.TabIndex = 162;
this.inbox4.Text = "Input 4";
//
// inbox1
//
this.inbox1.Location = new System.Drawing.Point(16, 48);
this.inbox1.Name = "inbox1";
this.inbox1.Size = new System.Drawing.Size(64, 16);
this.inbox1.TabIndex = 161;
this.inbox1.Text = "Input 1";
//
// label42
//
this.label42.Location = new System.Drawing.Point(88, 24);
this.label42.Name = "label42";
this.label42.Size = new System.Drawing.Size(16, 16);
this.label42.TabIndex = 166;
this.label42.Text = "X";
//
// tabPage2
//
this.tabPage2.Controls.Add(this.label36);
this.tabPage2.Controls.Add(this.vegTauCritBox);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(925, 530);
this.tabPage2.TabIndex = 7;
this.tabPage2.Text = "Vegetation";
//
// label36
//
this.label36.Location = new System.Drawing.Point(13, 28);
this.label36.Name = "label36";
this.label36.Size = new System.Drawing.Size(112, 24);
this.label36.TabIndex = 108;
this.label36.Text = "vegetation crit shear";
this.label36.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// vegTauCritBox
//
this.vegTauCritBox.Location = new System.Drawing.Point(127, 35);
this.vegTauCritBox.Name = "vegTauCritBox";
this.vegTauCritBox.Size = new System.Drawing.Size(71, 20);
this.vegTauCritBox.TabIndex = 92;
this.vegTauCritBox.Text = "180.0";
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 606);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.InfoStatusPanel,
this.IterationStatusPanel,
this.TimeStatusPanel,
this.QwStatusPanel,
this.QsStatusPanel,
this.tempStatusPanel});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(950, 22);
this.statusBar1.SizingGrip = false;
this.statusBar1.TabIndex = 144;
this.statusBar1.Text = "statusBar1";
this.statusBar1.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar1_PanelClick);
//
// InfoStatusPanel
//
this.InfoStatusPanel.Name = "InfoStatusPanel";
this.InfoStatusPanel.Text = "info";
this.InfoStatusPanel.Width = 200;
//
// IterationStatusPanel
//
this.IterationStatusPanel.Name = "IterationStatusPanel";
this.IterationStatusPanel.Text = "iterations";
this.IterationStatusPanel.Width = 120;
//
// TimeStatusPanel
//
this.TimeStatusPanel.Name = "TimeStatusPanel";
this.TimeStatusPanel.Text = "time";
this.TimeStatusPanel.Width = 120;
//
// QwStatusPanel
//
this.QwStatusPanel.Name = "QwStatusPanel";
this.QwStatusPanel.Text = "Qw";
this.QwStatusPanel.Width = 120;
//
// QsStatusPanel
//
this.QsStatusPanel.Name = "QsStatusPanel";
this.QsStatusPanel.Text = "Qs";
this.QsStatusPanel.Width = 120;
//
// tempStatusPanel
//
this.tempStatusPanel.Name = "tempStatusPanel";
this.tempStatusPanel.Text = "tempdata";
//
// start_button
//
this.start_button.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.start_button.Enabled = false;
this.start_button.Location = new System.Drawing.Point(256, 572);
this.start_button.Name = "start_button";
this.start_button.Size = new System.Drawing.Size(272, 24);
this.start_button.TabIndex = 146;
this.start_button.Text = "Start!";
this.start_button.Click += new System.EventHandler(this.main_loop);
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(536, 572);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(248, 24);
this.button1.TabIndex = 147;
this.button1.Text = "Quit and save";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(8, 8);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(112, 40);
this.button4.TabIndex = 144;
this.button4.Text = "update graphics";
this.button4.Click += new System.EventHandler(this.button4_Click_1);
//
// button3
//
this.button3.Font = new System.Drawing.Font("Monotype Corsiva", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button3.Location = new System.Drawing.Point(432, 32);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(184, 16);
this.button3.TabIndex = 99;
this.button3.Text = "Grass now!";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// tempdata1
//
this.tempdata1.Location = new System.Drawing.Point(528, 8);
this.tempdata1.Name = "tempdata1";
this.tempdata1.Size = new System.Drawing.Size(39, 20);
this.tempdata1.TabIndex = 98;
this.tempdata1.Text = "358";
//
// grassbox
//
this.grassbox.Location = new System.Drawing.Point(432, 8);
this.grassbox.Name = "grassbox";
this.grassbox.Size = new System.Drawing.Size(104, 24);
this.grassbox.TabIndex = 97;
this.grassbox.Text = "grass/sediment";
//
// recirculatebox
//
this.recirculatebox.Location = new System.Drawing.Point(240, 24);
this.recirculatebox.Name = "recirculatebox";
this.recirculatebox.Size = new System.Drawing.Size(168, 24);
this.recirculatebox.TabIndex = 89;
this.recirculatebox.Text = "recirculate sediment";
//
// checkBox3
//
this.checkBox3.Location = new System.Drawing.Point(240, 8);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(168, 24);
this.checkBox3.TabIndex = 68;
this.checkBox3.Text = "water surface smoothing";
//
// Panel1
//
this.Panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Panel1.Controls.Add(this.button5);
this.Panel1.Controls.Add(this.tempdata2);
this.Panel1.Controls.Add(this.button4);
this.Panel1.Controls.Add(this.button3);
this.Panel1.Controls.Add(this.tempdata1);
this.Panel1.Controls.Add(this.grassbox);
this.Panel1.Controls.Add(this.recirculatebox);
this.Panel1.Controls.Add(this.checkBox3);
this.Panel1.Location = new System.Drawing.Point(8, 508);
this.Panel1.Name = "Panel1";
this.Panel1.Size = new System.Drawing.Size(934, 56);
this.Panel1.TabIndex = 145;
this.Panel1.Visible = false;
//
// button5
//
this.button5.Location = new System.Drawing.Point(133, 7);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(80, 42);
this.button5.TabIndex = 146;
this.button5.Text = "scan";
this.button5.Click += new System.EventHandler(this.button5_Click_1);
//
// tempdata2
//
this.tempdata2.Location = new System.Drawing.Point(573, 7);
this.tempdata2.Name = "tempdata2";
this.tempdata2.Size = new System.Drawing.Size(39, 20);
this.tempdata2.TabIndex = 145;
this.tempdata2.Text = "358";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(950, 628);
this.Controls.Add(this.button1);
this.Controls.Add(this.start_button);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.button2);
this.Controls.Add(this.Panel1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "CAESAR - Cellular Automaton Evolutionary Slope And River model. version 4.92h";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.paint1);
this.Load += new System.EventHandler(this.Form1_Load);
this.tabControl1.ResumeLayout(false);
this.FilesTab.ResumeLayout(false);
this.FilesTab.PerformLayout();
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.NumericalTab.ResumeLayout(false);
this.NumericalTab.PerformLayout();
this.GrainTab.ResumeLayout(false);
this.GrainTab.PerformLayout();
this.DescriptionTab.ResumeLayout(false);
this.DescriptionTab.PerformLayout();
this.GridTab.ResumeLayout(false);
this.GridTab.PerformLayout();
this.HydrologyTab.ResumeLayout(false);
this.HydrologyTab.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.InfoStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.IterationStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.TimeStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.QwStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.QsStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tempStatusPanel)).EndInit();
this.Panel1.ResumeLayout(false);
this.Panel1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void start_button_Click(object sender, System.EventArgs e)
{
xtextbox.Visible=false;
ytextbox.Visible=false;
button1.Visible=false;
button2.Visible=false;
label1.Visible=false;
label2.Visible=false;
}
private void clearforms()
{
tabControl1.Visible = false;
}
// well, in this botched version of CAESAR for C#, main loop replaces main in the 'normal' version.
private void main_loop(object sender, System.EventArgs e)
{
/********* locals ***********/
int n;
double tempflow=baseflow;
double ince=cycle+60;
gameClock = new Timer();
// clearforms(); // MJ 14/01/05 this is done when load button is clicked
start_button.Enabled = false; // MJ 17/01/05
button1.Enabled = true; // MJ 17/01/05
time_1=1;
time_factor=60;
calc_J(1.0);
time_factor=1;
save_time=cycle;
creep_time=cycle;
time_1=cycle;
//this.Paint += new PaintEventHandler(paint1); //JMW
mygraphics = this.CreateGraphics();
slide(1);
get_area();
init_route(TRUE,init_discharge, baseflow);
this.InfoStatusPanel.Text="Starting main loop"; // MJ 14/01/05
//JMW
//MessageBox.Show("initialised route..", "Game Over", MessageBoxButtons.OK);
//MessageBox.Show("initialised route..", "Simulation", MessageBoxButtons.OK);
this.InfoStatusPanel.Text="Running"; // MJ 14/01/05
//
if (checkBoxGenerateAVIFile.Checked)
{
aw = new AviWriter();
string fname = textBoxAVIFile.Text;
//Delete the avi if it already exists, & wait for it to occur
if (File.Exists(fname))
{
File.Delete(fname);
if (File.Exists(fname))
{
System.IO.FileSystemWatcher watcher =
new System.IO.FileSystemWatcher(fname);
watcher.WaitForChanged(System.IO.WatcherChangeTypes.Deleted);
}
}
bmp = aw.Open(fname,25,this.ClientRectangle.Width,
this.ClientRectangle.Height); //
}
// Here we go into the main loop,
// not sure why its within a game clock thing, but I copied this bit of code to get
// the event handler to work - and it seems OK so why change it.
// so the main loop is really in erodedepo()
for(n=1;n<=1;n++)
{
gameClock.Interval = 1;
gameClock.Tick += new EventHandler(erodedepo);
gameClock.Start();
}
}
private void erodedepo(Object sender, EventArgs e)
{
// remember that this function is called every iteration from main_loop,
// so have to use global variables, or they get reset every time
int n,x,y;
//has to have erode first - otherwise it draws withoug the water - which is
//zero'd after erode.
// Gez code: set previous cycle = to cycle
previous = cycle;
old_cycle = cycle%output_file_save_interval;
// end gez code
counter++;
cycle+=time_factor/60; // cycle in mins, time_factor in seconds..
// Gez code
new_cycle = cycle%output_file_save_interval;
// end gez code
// then carry out soil creep. - also growing grass...
if(cycle>creep_time)
{
creep_time+=1440;// now daily..// now weekly //43800; // do soil creep monthly.
creep(0.0028);//(0.019);//(0.083);
// next line does grass growing, must change it if changes from monthly update
if(grow_grass_time>0)grow_grass(1/(grow_grass_time*365));
}
erode();
fill_pits(); // pit filling algorithm - experimental
if(newlateral.Checked)lateral2();//TJC 27/1/05
if(oldlateral.Checked)lateral();
slide_3();
//
// This whole section below deals with the water inputs. A separate part for point inputs and
// a different bit for gradual inputs from the whole of the catchment. (reach or catchment)
//
// carry out an init route every * iterations. normally 1000
if(Math.IEEERemainder(counter,2000)==0)
{
init_route(TRUE,init_discharge, baseflow);
time_factor=0.00000001;
}
if(reach_mode_box.Checked==true)
{
// if the input type flag is 0 then the discharge inputs are from points
j_mean=0;
double totqtemp=0;
for(n=0;n<=number_of_points-1;n++)
{
totqtemp+=inputfile[n,(int)((cycle-init_cycle)/input_time_step),1];
}
if(totqtemp>init_discharge)
{
init_discharge=init_discharge*2;
if(init_discharge80)
{
init_discharge=init_discharge/2;
Console.Write(" scanning down ");
init_route(TRUE,init_discharge,baseflow);
time_factor=0.0000000001;
}
for(n=0;n<=number_of_points-1;n++)
{
x=inpoints[n,0];
y=inpoints[n,1];
discharge[x, y] += inputfile[n, (int)((cycle - init_cycle) / input_time_step), 1];
}
}
if(catchment_mode_box.Checked==true)
{
// if the input type flag is 1 then the discharge is input from the hydrograph...
if(cycle>=time_1)
{
do
{
time_1+=2;
calc_J(time_1);
if(time_factor>3600&&new_j_mean>(0.2/3000000))
{
cycle=time_1+60;
time_factor=3600;
}
}while(time_1=baseflow)
{
baseflow=baseflow*2;
Console.Write("goig up.. \n");
get_area();
init_route(TRUE,init_discharge, baseflow);
time_factor=0.0000000001;
}
if(baseflow>(j_mean*2)&&baseflow>0.0000005)
{
baseflow=j_mean*1.01;
Console.Write("going down.. \n");
get_area();
init_route(TRUE,init_discharge, baseflow);
time_factor=0.0000000001;
}
}
//
// Now goes into the four scans for routing water.
// Here it actually has 8, sometimes this works better.
//
//Console.WriteLine(Convert.ToString(j_mean*DX*DX*nActualGridCells));
for(x=1;x<=xmax;x++){for(y=1;y<=ymax;y++){elev[x,y]+=pool_depth[x,y];}}
route_lr();//drawwater(mygraphics);for(t=1;t<=50000000;t++);
route_rl();//drawwater(mygraphics);for(t=1;t<=50000000;t++);
route_down(cycle);//drawwater(mygraphics);for(t=1;t<=50000000;t++);
route_up();//drawwater(mygraphics);for(t=1;t<=50000000;t++);
for (n = 0; n <= number_of_points - 1; n++)
{
x = inpoints[n, 0];
y = inpoints[n, 1];
discharge[x, y] += inputfile[n, (int)((cycle - init_cycle) / input_time_step), 1];
}
route_lr();//drawwater(mygraphics);for(t=1;t<=50000000;t++);
route_rl();//drawwater(mygraphics);for(t=1;t<=50000000;t++);
route_up();//drawwater(mygraphics);for(t=1;t<=50000000;t++);
route_down(cycle);//drawwater(mygraphics);for(t=1;t<=50000000;t++);
for(x=1;x<=xmax;x++){for(y=1;y<=ymax;y++){elev[x,y]-=pool_depth[x,y];if(water_depth[x,y]>0)water_depth[x,y]+=pool_depth[x,y];}}
// water surface smoothing routine called
if (checkBox3.Checked == true) smooth(smoothradius); //passes radius for smoothing to smooth function
// then calculate flow direction and velocity
calc_flow_direction();
//calc_flow_velocity(); //
//smooth_tau(1);
smooth_discharge(1);
//if(wslope_box.Checked==true)smooth_tau(1); // has to go after calc_flow direction, where Tau is also calcualterd..
// interestingly found that if this is checked when using bed slope, then stripey erosion aand deposition
// patterns are formed. But is needed with WS slope. Therefore set up so can only work with WS slope. TJC 15/1/2006
// then calculate soil saturation
// calc_soil_saturation(); //
// this simple for next loop just calcualtes the total discharge that drops off the right end of the map
double temptot=0;
double erotemp=0;
for(y=1;y<=ymax;y++)
{
if(discharge[xmax+1,y]>0)
{
temptot+=discharge[xmax+1,y];
discharge[xmax+1,y]=0;
}
for(x=1;x<=xmax;x++)
{
erotemp+=init_elevs[x,y]-elev[x,y];
}
}
// Gez
temptotal = temptot;
// call output routine
if (checkBoxGenerateTimeSeries.Checked) // MJ 20/01/05
{
output_data();
}
// end gez code
//this.qoutbox1.Text=Convert.ToString(temptot);
//this.tempdata.Text=Convert.ToString(erotemp*DX*DX);
this.QwStatusPanel.Text=string.Format("Qw = {0:G}",temptot); // MJ 14/01/05
// this.tempStatusPanel.Text=string.Format("tmp = {0:F6}",j_mean*DX*DX*nActualGridCells); // MJ 29/03/05
// updates the text boxes with the time and iterationbs elapsed
//this.disptextbox.Text=Convert.ToString(counter); //JMW
//this.timeelapsedbox.Text=Convert.ToString(cycle); //JMW
this.IterationStatusPanel.Text= "it = " + counter.ToString(); // MJ 14/01/05
if (cycle <= 1440)
{
this.TimeStatusPanel.Text=string.Format("t = {0:F6} min",cycle);
}
else
{
this.TimeStatusPanel.Text=string.Format("t = {0:F6} day",cycle/1440);
}
// output of iteration essentials MJ 19/01/05
if (checkBoxGenerateIterations.Checked)
{
string ITERATION_FILE = IterationOutbox.Text;
string output = string.Format("{0:G}",counter);
output = output + string.Format(" {0:F6}",cycle/1440); // fixed JOE 18/05/05
output = output + string.Format(" {0:F6}",temptot);
output = output + string.Format(" {0:F6}",sediQ);
output = output + string.Format(" {0:F6}",j_mean*DX*DX*nActualGridCells); // fixed MJ 29/03/05
StreamWriter sw = File.AppendText(ITERATION_FILE);
sw.WriteLine(output);
sw.Close();
}
// update the graphics every X times (here 10)
if(Math.IEEERemainder(counter,100)==0)
{
this.Refresh();
drawwater(mygraphics); //
}
// save data every X times.. passes 0 to save data which means it gets no file extension
if(Math.IEEERemainder(counter,100)==0)
{
if(menuItem25.Checked==true)save_data(1,0); // save waterdepths
if(menuItem13.Checked==true)save_data(2,0); // save elevdiff
if(menuItem12.Checked==true)save_data(3,0); // save elevations
if(menuItem14.Checked==true)save_data(4,0); // save grainsize
if(menuItem15.Checked==true)save_data(5,0); // save tracer grainsizes
if(menuItem16.Checked==true)save_data(6,0); // save tracer surface
if(menuItem17.Checked==true)save_data(7,0); // save tracer 2
if(menuItem18.Checked==true)save_data(8,0); // save tracer 3
if(menuItem19.Checked==true)save_data(9,0); // save tracer 4
if(menuItem20.Checked==true)save_data(10,0); // save tracer 5
if(menuItem21.Checked==true)save_data(11,0); // save tracer 6
if(menuItem22.Checked==true)save_data(12,0); // save tracer 7
if(menuItem23.Checked==true)save_data(13,0); // save tracer 8
if(menuItem24.Checked==true)save_data(14,0); // save tracer 9
if(menuItem29.Checked==true)save_data(15,0); // save d50 top layer
if(menuItem33.Checked==true)save_data(16,0); // save velocity
if(menuItem34.Checked==true)save_data(17,0); // save soil_saturation
slide(1);
}
//JMW 20041110 - Update plots
//
// drawwater(mygraphics); //
//
// //Repaint the form
// this.Update();
// save data every specified interval. Passes the cycle whuch becomes the file extension
if(cycle>=save_time)
{
if(menuItem25.Checked==true)save_data(1,Math.Abs(cycle)); // save waterdepths
if(menuItem13.Checked==true)save_data(2,Math.Abs(cycle)); // save elevdiff
if(menuItem12.Checked==true)save_data(3,Math.Abs(cycle)); // save elevations
if(menuItem14.Checked==true)save_data(4,Math.Abs(cycle)); // save grainsize
if(menuItem15.Checked==true)save_data(5,Math.Abs(cycle)); // save tracer grainsizes
if(menuItem16.Checked==true)save_data(6,Math.Abs(cycle)); // save tracer surface
if(menuItem17.Checked==true)save_data(7,Math.Abs(cycle)); // save tracer 2
if(menuItem18.Checked==true)save_data(8,Math.Abs(cycle)); // save tracer 3
if(menuItem19.Checked==true)save_data(9,Math.Abs(cycle)); // save tracer 4
if(menuItem20.Checked==true)save_data(10,Math.Abs(cycle)); // save tracer 5
if(menuItem21.Checked==true)save_data(11,Math.Abs(cycle)); // save tracer 6
if(menuItem22.Checked==true)save_data(12,Math.Abs(cycle)); // save tracer 7
if(menuItem23.Checked==true)save_data(13,Math.Abs(cycle)); // save tracer 8
if(menuItem24.Checked==true)save_data(14,Math.Abs(cycle)); // save tracer 9
if(menuItem29.Checked==true)save_data(15,Math.Abs(cycle)); // save d50 top layer
if(menuItem33.Checked==true)save_data(16,Math.Abs(cycle)); // save velocity
if(menuItem34.Checked==true)save_data(17,Math.Abs(cycle)); // save soil saturation
//JMW 20041110 - Output frame to avi file
if (checkBoxGenerateAVIFile.Checked)
{
this.Refresh(); // tjc to enable graphics to be drwan before senbding to AVI
drawwater(mygraphics); // tjc
Graphics gbmp = Graphics.FromImage(bmp);
if (gbmp != null)
{
IntPtr dc1 = mygraphics.GetHdc();
IntPtr dc2 = gbmp.GetHdc();
BitBlt(dc2,0,0,this.ClientRectangle.Width,this.ClientRectangle.Height,
dc1,0,0, 13369376);
mygraphics.ReleaseHdc(dc1);
gbmp.ReleaseHdc(dc2);
// need to flip image to get it the correct way up in the avi - not sure why.
bmp.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY);
try
{
aw.AddFrame();
}
catch (AviWriter.AviException ex) //
{
aw.Close();
Console.WriteLine("AVI Exception in: " + ex.ToString());
}
//form2.Show();
}
}
slide(1);
save_time+=saveinterval;
}
if(time_factor>1200)time_factor=1200;// just temp 14400
// if its at the end of the run kill the program
if(counter>maxiterations||cycle>maxcycle*60)
{
gameClock.Stop();
gameClock.Dispose();
if ((checkBoxGenerateAVIFile.Checked) & (aw != null))
aw.Close(); //JMW 20041109
}
}
void calchydrograph(double time)
{
j_mean=old_j_mean+(((new_j_mean-old_j_mean)/2)*(2-time));
}
private void paint1(Object sender, PaintEventArgs e)
{
//graphics = e.Graphics;
//drawwater(this);
//if (DoingGraphics)
//{
// Graphics g = e.Graphics;
// drawwater(g); //JMW
//}
}
void output_data()
{
int n;
// Qw (m3) value at timestep cycle (current
// Qw_newvol+=temptotal*((cycle-previous)*output_file_save_interval); // replaced by line below MJ 25/01/05
Qw_newvol+=temptotal*((cycle-previous)*60); // 60 secs per min
Jw_newvol += (j_mean*DX*DX*nActualGridCells) * ((cycle-previous)*60);
//Catch all time steps that pass one or more hour marks
if ((new_cycle=output_file_save_interval))
{
while ((tx>previous)&&(cycle>=tx))
{
hours++;
// Step1: Calculate hourly total sediment Q (m3)
Qs_step = globalsediq-old_sediq;
Qs_over = Qs_step*((cycle-tx)/(cycle-tlastcalc));
Qs_hour = Qs_step-Qs_over+Qs_last;
// reset Qs_last and old_sediq for large time steps
if (cycle>=tx+output_file_save_interval)
{
Qs_last = 0;
old_sediq = globalsediq - Qs_over;
}
// reset Qs_last and old_sediq for small time steps
if (cycle=tx+output_file_save_interval)
{
Qg_last[n] = 0;
old_sum_grain[n] = sum_grain[n] - Qg_over[n];
}
// Reset Qg_last[n] and old_sum_grain[n] for small time steps
if (cycle=tx+output_file_save_interval)
{
Qw_lastvol = 0;
Qw_oldvol = Qw_newvol-Qw_overvol;
// same for Jw (j_mean contribution) MJ 14/03/05
Jw_lastvol = 0;
Jw_oldvol = Jw_newvol-Jw_overvol;
}
// reset Qw_lastvol and Qw_oldvol for small time steps
if (cycle=0.0001||init_elevs[x,y]-elev[x,y]<=-0.0001)d2++;
// if(init_elevs[x,y]-elev[x,y]>=0.0005||init_elevs[x,y]-elev[x,y]<=-0.0005)d3++;
// if(init_elevs[x,y]-elev[x,y]>=0.001||init_elevs[x,y]-elev[x,y]<=-0.001)d4++;
// if(init_elevs[x,y]-elev[x,y]>=0.005||init_elevs[x,y]-elev[x,y]<=-0.005)d5++;
// init_elevs[x,y]=elev[x,y];
// }
//
// }
//
// output = output+" total "+d1;
// output = output+" "+d2;
// output = output+" "+d3;
// output = output+" "+d4;
// output = output+" "+d5;
// end of elev change bit..
StreamWriter sw = File.AppendText(CATCH_FILE);
sw.WriteLine(output);
sw.Close();
}
tlastcalc = cycle;
}
}
//============================================================================
private void smooth(int radius)
{
int x,y,inc,tot=0,x1,y1;
double temp_height=0;
for(x=1;x<=(xmax);x++)
{
inc=1;
while(cross_scan[x,inc]>0)
{
y=cross_scan[x,inc];
inc++;
water_depth2[x,y]=water_depth[x,y];
temp_depth[x,y]=0;
if(water_depth[x,y]>water_depth_erosion_threshold)
{
temp_height=0;
tot=0;
double mean_ws_elev=0;
int tempxmin=-radius;
int tempxmax=radius;
int tempymin=-radius;
int tempymax=radius;
while(x+tempxmin<1)tempxmin++;
while(x+tempxmax>xmax)tempxmax--;
while(y+tempymin<1)tempymin++;
while(y+tempymax>ymax)tempymax--;
for(x1=tempxmin;x1<=tempxmax;x1++)
{
for(y1=tempymin;y1<=tempymax;y1++)
{
if(water_depth[x+x1,y+y1]>water_depth_erosion_threshold)
{
temp_height+=(water_depth[x+x1,y+y1]+elev[x+x1,y+y1]);
tot++;
}
// if(x1==0&&y1==0) // added to double impact of central cell in the filter
// {
// temp_height+=(water_depth[x+x1,y+y1]+elev[x+x1,y+y1]);
// tot++;
// }
}
}
mean_ws_elev=temp_height/tot;
if((water_depth[x,y]+elev[x,y])>mean_ws_elev)
{
if(water_depth[x,y]>((water_depth[x,y]+elev[x,y])-mean_ws_elev))
{
temp_depth[x,y]=(mean_ws_elev-(water_depth[x,y]+elev[x,y]));
}
if(water_depth[x,y]<((water_depth[x,y]+elev[x,y])-mean_ws_elev))
{
temp_depth[x,y]=0.0-water_depth[x,y];
}
if(temp_depth[x,y]+water_depth[x,y]0)
{
y=cross_scan[x,inc];
inc++;
if(temp_depth[x,y]!=0)
{
// check to stop above completely removing water from cells
water_depth[x,y]+=temp_depth[x,y];
if(water_depth[x,y]<0)water_depth[x,y]=0;
temp_depth[x,y]=0;
}
}
}
}
private void smooth_discharge(int radius)
{
int x,y,inc,x1,y1;
for(x=1;x<=(xmax);x++)
{
inc=1;
while(cross_scan[x,inc]>0)
{
y=cross_scan[x,inc];
inc++;
temp_depth[x,y]=0;
}
}
for(x=1;x<=(xmax);x++)
{
inc=1;
while(cross_scan[x,inc]>0)
{
y=cross_scan[x,inc];
inc++;
if(discharge[x,y]>0)
{
int tempnum=0;
int tempxmin=-radius;
int tempxmax=radius;
int tempymin=-radius;
int tempymax=radius;
while(x+tempxmin<1)tempxmin++;
while(x+tempxmax>xmax)tempxmax--;
while(y+tempymin<1)tempymin++;
while(y+tempymax>ymax)tempymax--;
for(x1=tempxmin;x1<=tempxmax;x1++)
{
for(y1=tempymin;y1<=tempymax;y1++)
{
if(water_depth[x+x1,y+y1]>=0.01)tempnum++;
}
}
tempxmin=-radius;
tempxmax=radius;
tempymin=-radius;
tempymax=radius;
while(x+tempxmin<1)tempxmin++;
while(x+tempxmax>xmax)tempxmax--;
while(y+tempymin<1)tempymin++;
while(y+tempymax>ymax)tempymax--;
for(x1=tempxmin;x1<=tempxmax;x1++)
{
for(y1=tempymin;y1<=tempymax;y1++)
{
if(water_depth[x+x1,y+y1]>=0.01)
{
temp_depth[x+x1,y+y1]+=discharge[x,y]/tempnum;
temp_depth[x,y]-=discharge[x,y]/tempnum;
}
}
}
}
}
}
for(x=1;x<=(xmax);x++)
{
inc=1;
while(cross_scan[x,inc]>0)
{
y=cross_scan[x,inc];
inc++;
discharge[x,y]+=temp_depth[x,y];
}
}
}
int read_header()
{
string FILE_NAME;
int z;
string[] lineArray2;
int sp;
inputheader = new string[6];
FILE_NAME = this.openfiletextbox.Text;
if (!File.Exists(FILE_NAME))
{
MessageBox.Show("No such DEM data file..");
return 0;
}
try
{
//read headers
StreamReader sr = File.OpenText(FILE_NAME);
for(z = 1; z <= 6; z++)
{
inputheader[z-1] = sr.ReadLine();
}
sr.Close();
// get xmax, ymax and DX from input headers
lineArray2 = inputheader[0].Split(new char[]{' '});
sp = 1;
while (lineArray2[sp] == "") sp++;
xmax = int.Parse(lineArray2[sp]);
lineArray2 = inputheader[1].Split(new char[]{' '});
sp = 1;
while (lineArray2[sp] == "") sp++;
ymax = int.Parse(lineArray2[sp]);
lineArray2 = inputheader[4].Split(new char[]{' '});
sp = 1;
while (lineArray2[sp] == "") sp++;
DX = int.Parse(lineArray2[sp]);
}
catch(Exception ex)
{
MessageBox.Show("Theres a problem with the header in the DEM file");
}
return 1;
}
void load_data()
{
int x,y=1,z,xcounter,x1=0,y1=0,n;
String input;
double tttt=0.00;
// load dem
string FILE_NAME = this.openfiletextbox.Text;
if (!File.Exists(FILE_NAME))
{
MessageBox.Show("No such DEM data file..");
return;
}
StreamReader sr = File.OpenText(FILE_NAME);
//read headers
for(z=1;z<=6;z++)
{
input=sr.ReadLine();
}
y=1;
while ((input=sr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
xcounter=1;
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!=""&&xcounter<=xmax)
{
tttt=double.Parse(lineArray[x]);
elev[xcounter,y]=tttt;
//if(xcounter==1)elev[xcounter,y]+=4;
init_elevs[xcounter,y]=elev[xcounter,y];
xcounter++;
}
}
y++;
}
sr.Close();
if(this.graindataloadbox.Text!="null")
{
FILE_NAME = this.graindataloadbox.Text;
if(FILE_NAME!="null")
{
StreamReader gr = File.OpenText(FILE_NAME);
y=1;
grain_array_tot=0;
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
xcounter=1;
grain_array_tot++;
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
if(xcounter==1)x1=int.Parse(lineArray[x]);
if(xcounter==2)y1=int.Parse(lineArray[x]);
if(xcounter==3)index[x1,y1]=grain_array_tot;
for(n=0;n<=G_MAX;n++)
{
if(xcounter==4+n)
{
grain[grain_array_tot,n,0]=double.Parse(lineArray[x]);
}
}
for(z=0;z<=9;z++)
{
for(n=0;n<=(G_MAX-2);n++)
{
if(xcounter==(4+G_MAX+n+1)+((z)*9))
{
strata[grain_array_tot,z,n,0]=double.Parse(lineArray[x]);
}
}
}
xcounter++;
}
}
}
gr.Close();
}
}
FILE_NAME = this.bedrockbox.Text;
if(FILE_NAME!="null")
{
StreamReader gr = File.OpenText(FILE_NAME);
//read headers
for(z=1;z<=6;z++)
{
input=gr.ReadLine();
}
y=1;
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
xcounter=1;
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tttt=double.Parse(lineArray[x]);
bedrock[xcounter,y]=tttt;
xcounter++;
}
}
y++;
}
gr.Close();
}
try
{
FILE_NAME = this.raindataloadbox.Text;
if (FILE_NAME != "null")
{
input_type_flag = 1;
int inc = 1;
// Random R =new Random();
StreamReader gr = File.OpenText(FILE_NAME);
while ((input = gr.ReadLine()) != null)
{
hourly_rain_data[inc] = double.Parse(input);
// // adding random rain bit.
//
// if(hourly_rain_data[inc]>0)
// {
// hourly_rain_data[inc]=(R.Next(1,30));
// }
//Console.WriteLine(hourly_rain_data[inc]);
// string[] lineArray;
// lineArray = input.Split(new char[]{' '});
// for (x = 0; x<(lineArray.Length-1); x++)
// {
// if(lineArray[x]!="")
// {
// hourly_rain_data[inc]=double.Parse(lineArray[x]);
// Console.WriteLine("loading raindata \n");
// Console.WriteLine(lineArray[x]);
// }
// }
inc++;
}
gr.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("There was some type of error loading the input data from the rain data file CAESAR may continue to function but may not be correct");
}
int tempx=0;
try
{
if(inbox1.Checked)
{
FILE_NAME = this.infile1.Text;
if(FILE_NAME!="null")
{
input_type_flag=0;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tempx=int.Parse(lineArray[0]);
inputfile[0,tempx-(((int)(init_cycle))/input_time_step),x]=double.Parse(lineArray[x]);
}
}
}
gr.Close();
}
}
if(inbox2.Checked)
{
FILE_NAME = this.infile2.Text;
if(FILE_NAME!="null")
{
input_type_flag=0;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tempx=int.Parse(lineArray[0]);
inputfile[1,tempx-(((int)(init_cycle))/input_time_step),x]=double.Parse(lineArray[x]);
}
}
}
gr.Close();
}
}
if(inbox3.Checked)
{
FILE_NAME = this.infile3.Text;
if(FILE_NAME!="null")
{
input_type_flag=0;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tempx=int.Parse(lineArray[0]);
inputfile[2,tempx-(((int)(init_cycle))/input_time_step),x]=double.Parse(lineArray[x]);
}
}
}
gr.Close();
}
}
if(inbox4.Checked)
{
FILE_NAME = this.infile4.Text;
if(FILE_NAME!="null")
{
input_type_flag=0;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tempx=int.Parse(lineArray[0]);
inputfile[3,tempx-(((int)(init_cycle))/input_time_step),x]=double.Parse(lineArray[x]);
}
}
}
gr.Close();
}
}
if(inbox5.Checked)
{
FILE_NAME = this.infile5.Text;
if(FILE_NAME!="null")
{
input_type_flag=0;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tempx=int.Parse(lineArray[0]);
inputfile[4,tempx-(((int)(init_cycle))/input_time_step),x]=double.Parse(lineArray[x]);
}
}
}
gr.Close();
}
}
if(inbox6.Checked)
{
FILE_NAME = this.infile6.Text;
if(FILE_NAME!="null")
{
input_type_flag=0;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tempx=int.Parse(lineArray[0]);
inputfile[5,tempx-(((int)(init_cycle))/input_time_step),x]=double.Parse(lineArray[x]);
}
}
}
gr.Close();
}
}
if(inbox7.Checked)
{
FILE_NAME = this.infile7.Text;
if(FILE_NAME!="null")
{
input_type_flag=0;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tempx=int.Parse(lineArray[0]);
inputfile[6,tempx-(((int)(init_cycle))/input_time_step),x]=double.Parse(lineArray[x]);
}
}
}
gr.Close();
}
}
if(inbox8.Checked)
{
FILE_NAME = this.infile8.Text;
if(FILE_NAME!="null")
{
input_type_flag=0;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
tempx=int.Parse(lineArray[0]);
inputfile[7,tempx-(((int)(init_cycle))/input_time_step),x]=double.Parse(lineArray[x]);
}
}
}
gr.Close();
}
}
}
catch(Exception ex)
{
MessageBox.Show("There was some type of error loading the input data from "+FILE_NAME+" at line "+Convert.ToString(tempx)+", CAESAR will continue to function but may not be correct");
}
FILE_NAME = this.tracerfile.Text;
if(FILE_NAME!="null")
{
int lineinc=1;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
int inc=1;
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
if(inc==1)tracerinput[lineinc,inc]=double.Parse(lineArray[x]);
if(inc==2)tracerinput[lineinc,inc]=double.Parse(lineArray[x]);
if(inc==3)tracerinput[lineinc,inc]=double.Parse(lineArray[x]);
if(inc==4)tracerinput[lineinc,inc]=double.Parse(lineArray[x]);
inc++;
}
}
lineinc++;
}
gr.Close();
tot_number_of_tracer_points=lineinc;
}
FILE_NAME = this.tracerhydrofile.Text;
if(FILE_NAME!="null")
{
int lineinc=1;
StreamReader gr = File.OpenText(FILE_NAME);
while ((input=gr.ReadLine())!=null)
{
int temp1=0;
int inc=1;
string[] lineArray;
lineArray = input.Split(new char[]{' '});
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
if(inc==1)temp1=int.Parse(lineArray[x]);
if(inc==2)tracerhydrograph[temp1,0]=double.Parse(lineArray[x]);
if(inc==3)tracerhydrograph[temp1,1]=double.Parse(lineArray[x]);
inc++;
}
}
lineinc++;
}
gr.Close();
}
if(this.tracergrainbox.Text!="null"&&TRACERS>1)
{
FILE_NAME = this.graindataloadbox.Text;
if(FILE_NAME!="null")
{
StreamReader gr = File.OpenText(FILE_NAME);
y=1;
grain_array_tot=0;
while ((input=gr.ReadLine())!=null)
{
string[] lineArray;
lineArray = input.Split(new char[]{' '});
xcounter=1;
grain_array_tot++;
for (x = 0; x<=(lineArray.Length-1); x++)
{
if(lineArray[x]!="")
{
if(xcounter==1)x1=int.Parse(lineArray[x]);
if(xcounter==2)y1=int.Parse(lineArray[x]);
if(xcounter==3)index[x1,y1]=grain_array_tot;
for(n=0;n<=G_MAX;n++)
{
if(xcounter==4+n)
{
grain[grain_array_tot,n,1]=double.Parse(lineArray[x]);
}
}
for(z=0;z<=9;z++)
{
for(n=0;n<=(G_MAX-2);n++)
{
if(xcounter==(4+G_MAX+n+1)+((z)*9))
{
strata[grain_array_tot,z,n,1]=double.Parse(lineArray[x]);
}
}
}
xcounter++;
}
}
}
gr.Close();
}
}
// MessageBox.Show(Convert.ToString(input_type_flag));
this.InfoStatusPanel.Text="Loaded: type = " + input_type_flag.ToString(); // MJ 02/02/05
}
void save_data(int typeflag, double tempcycle)
{
int x,y,n,z,inc, p,nn;
double ztemp;
string FILENAME = "waterdepth.dat";
if(uniquefilecheck.Checked==false)tempcycle=0;
// turns file name into days from mins.
tempcycle=tempcycle/1440;
if(typeflag==1&&tempcycle==0) FILENAME = "waterdepth.txt";
if(typeflag==2&&tempcycle==0) FILENAME = "elevdiff.txt";
if(typeflag==3&&tempcycle==0) FILENAME = "elev.txt";
if(typeflag==4&&tempcycle==0) FILENAME = "grain.txt";
if(typeflag==5&&TRACERS>1&&tempcycle==0) FILENAME = "tracergrain.txt";
if (typeflag == 6 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer1.txt";
if (typeflag == 7 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer2.txt";
if (typeflag == 8 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer3.txt";
if (typeflag == 9 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer4.txt";
if (typeflag == 10 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer5.txt";
if (typeflag == 11 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer6.txt";
if (typeflag == 12 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer7.txt";
if (typeflag == 13 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer8.txt";
if (typeflag == 14 && TRACERS > 1 && tempcycle == 0) FILENAME = "tracer9.txt";
if (typeflag == 15 && tempcycle == 0) FILENAME = "d50top.txt";
if (typeflag == 16 && tempcycle == 0) FILENAME = "velocity.txt"; //
if (typeflag == 17 && tempcycle == 0) FILENAME = "soil_saturation.txt"; //
if(typeflag==1&&tempcycle>0) FILENAME = "waterdepth.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==2&&tempcycle>0) FILENAME = "elevdiff.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==3&&tempcycle>0) FILENAME = "elev.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==4&&tempcycle>0) FILENAME = "grain.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==5&&TRACERS>1&&tempcycle>0) FILENAME = "tracergrain.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==6&&TRACERS>1&&tempcycle>0) FILENAME = "tracer1.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==7&&TRACERS>1&&tempcycle>0) FILENAME = "tracer2.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==8&&TRACERS>1&&tempcycle>0) FILENAME = "tracer3.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==9&&TRACERS>1&&tempcycle>0) FILENAME = "tracer4.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==10&&TRACERS>1&&tempcycle>0) FILENAME = "tracer5.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==11&&TRACERS>1&&tempcycle>0) FILENAME = "tracer6.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==12&&TRACERS>1&&tempcycle>0) FILENAME = "tracer7.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==13&&TRACERS>1&&tempcycle>0) FILENAME = "tracer8.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==14&&TRACERS>1&&tempcycle>0) FILENAME = "tracer9.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==15&&tempcycle>0) FILENAME = "d50top.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle));
if(typeflag==16&&tempcycle>0) FILENAME = "velocity.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle)); //
if(typeflag==17&&tempcycle>0) FILENAME = "soil_saturation.dat"+"."+Convert.ToString(Convert.ToInt64(tempcycle)); //
if(typeflag>=1&&typeflag<4)
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
sw.Write("ncols "+xmax);
sw.Write("\n");
sw.Write("nrows "+ymax);
sw.Write("\n");
for (nn=2; nn<=5; nn++)
{
sw.Write(inputheader[nn]);sw.Write("\n");
}
for(y=1;y<=ymax;y++)
{
for(x=1;x<=xmax;x++)
{
if(typeflag==1)
{
if(water_depth[x,y]>0)
{
sw.Write(max_flow[x,y,0]);
sw.Write(" ");
}
else
{
sw.Write("-9999.0");
sw.Write(" ");
}
}
if(typeflag==2)
{
sw.Write(init_elevs[x,y]-elev[x,y]);
sw.Write(" ");
}
if(typeflag==3)
{
sw.Write(elev[x,y]);
sw.Write(" ");
}
}
sw.Write("\n");
}
}
}
if(typeflag==4)
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
for (y=1;y<=ymax;y++)
{
for(x=1;x<=xmax;x++)
{
if(index[x,y]!=-9999)
{
sw.Write(x);sw.Write(" ");sw.Write(y);sw.Write(" ");sw.Write(index[x,y]);sw.Write(" ");
for(inc=0;inc<=G_MAX;inc++)
{
sw.Write(grain[index[x,y],inc,0]);sw.Write(" ");
}
for(z=0;z<=9;z++)
{
for(inc=0;inc<=(G_MAX-2);inc++)
{
sw.Write(strata[index[x,y],z,inc,0]);sw.Write(" ");
}
}
sw.Write("\n");
}
}
}
}
}
if(typeflag==5&&TRACERS>1)
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
for (y=1;y<=ymax;y++)
{
for(x=1;x<=xmax;x++)
{
if(index[x,y]!=-9999)
{
sw.Write(x);sw.Write(" ");sw.Write(y);sw.Write(" ");sw.Write(index[x,y]);sw.Write(" ");
for(inc=0;inc<=G_MAX;inc++)
{
sw.Write(grain[index[x,y],inc,1]);sw.Write(" ");
}
for(z=0;z<=9;z++)
{
for(inc=0;inc<=(G_MAX-2);inc++)
{
sw.Write(strata[index[x,y],z,inc,1]);sw.Write(" ");
}
}
sw.Write("\n");
}
}
}
}
}
if(typeflag==6&&TRACERS>1)
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
for (nn=0; nn<=5; nn++)
{
sw.Write(inputheader[nn]);sw.Write("\n");
}
for(y=1;y<=ymax;y++)
{
for(x=1;x<=xmax;x++)
{
if(index[x,y]!=-9999)
{
ztemp=0;
for(n=1;n1)
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
for (nn=0; nn<=5; nn++)
{
sw.Write(inputheader[nn]);sw.Write("\n");
}
for(y=1;y<=ymax;y++)
{
for(x=1;x<=xmax;x++)
{
if(index[x,y]!=-9999)
{
ztemp=0.0;
for(n=1;n<=(G_MAX-2);n++)
{
ztemp+=(strata[index[x,y],p-7,n,1]);
}
sw.Write(ztemp);sw.Write(" ");
}
else
{
sw.Write("-9999.0 ");
}
}
sw.Write("\n");
}
}
}
}
if(typeflag==15)
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
for (nn=0; nn<=5; nn++)
{
sw.Write(inputheader[nn]);sw.Write("\n");
}
for(y=1;y<=ymax;y++)
{
for(x=1;x<=xmax;x++)
{
if(index[x,y] == -9999)
{
sw.Write("-9999.0");
sw.Write(" ");
}
else
{
sw.Write(d50(index[x,y]));
sw.Write(" ");
}
}
sw.Write("\n");
}
}
}
if(typeflag==16) // Write velocity to a file
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
for (nn=0; nn<=5; nn++)
{
sw.Write(inputheader[nn]);sw.Write("\n");
}
for(y=1;y<=ymax;y++)
{
for(x=1;x<=xmax;x++)
{
if(index[x,y] == -9999)
{
sw.Write("-9999.0");
sw.Write(" ");
}
else
{
// flow_velocity[x,y,n] where n = 0 is maximum,
// n =9 is sum in all directions
sw.Write(flow_velocity[x,y,0]);
sw.Write(" ");
}
}
sw.Write("\n");
}
}
}
if(typeflag==17) // Write soil_saturation to a file
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
for (nn=0; nn<=5; nn++)
{
sw.Write(inputheader[nn]);sw.Write("\n");
}
for(y=1;y<=ymax;y++)
{
for(x=1;x<=xmax;x++)
{
if(index[x,y] == -9999)
{
sw.Write("-9999.0");
sw.Write(" ");
}
else
{
sw.Write(soil_saturation[x,y]);
sw.Write(" ");
}
}
sw.Write("\n");
}
}
}
}
private void initialise()
{
this.InfoStatusPanel.Text="Initialising.."; // MJ 14/01/05
if (overrideheaderBox.Checked == true)
{
// input xmax, ymax and DX from text boxes
xmax=int.Parse(xtextbox.Text);
ymax=int.Parse(ytextbox.Text);
DX=int.Parse(dxbox.Text); // now in read_header() MJ 24/05/05
}
if(tracerbox.Checked==true)TRACERS=2;
init_route_number_of_scans=int.Parse(initscansbox.Text);
ERODEFACTOR=double.Parse(erodefactorbox.Text);
root=(Math.Sqrt(Math.Pow(DX,2)+Math.Pow(DX,2)));
fiveroot=(Math.Sqrt(Math.Pow(DX,2)+Math.Pow(DX,2)));
LIMIT=int.Parse(limitbox.Text);
MIN_Q=double.Parse(minqbox.Text);
CREEP_RATE=double.Parse(creepratebox.Text);
lateral_constant=double.Parse(lateralratebox.Text);
maxiterations=int.Parse(itermaxbox.Text);
cycle=double.Parse(textBox1.Text)*60;
init_cycle=cycle;
maxcycle=int.Parse(cyclemaxbox.Text);
failureangle=double.Parse(slopebox.Text);
smoothradius=int.Parse(smoothbox.Text);
saveinterval=double.Parse(saveintervalbox.Text);
M=double.Parse(mvaluebox.Text);
grow_grass_time=double.Parse(grasstextbox.Text);
output_file_save_interval=int.Parse(outputfilesaveintervalbox.Text);
tx=output_file_save_interval;
min_time_step=double.Parse(mintimestepbox.Text);
active=double.Parse(activebox.Text);
k_evap=double.Parse(k_evapBox.Text); // added MJ 15/03/05
vegTauCrit=double.Parse(vegTauCritBox.Text); // added MJ 10/05/05
cross_stream_grad_factor=double.Parse(cross_stream_grad_box.Text);
d1=double.Parse(g1box.Text);
d2=double.Parse(g2box.Text);
d3=double.Parse(g3box.Text);
d4=double.Parse(g4box.Text);
d5=double.Parse(g5box.Text);
d6=double.Parse(g6box.Text);
d7=double.Parse(g7box.Text);
d8=double.Parse(g8box.Text);
d9=double.Parse(g9box.Text);
d1prop=double.Parse(gp1box.Text);
d2prop=double.Parse(gp2box.Text);
d3prop=double.Parse(gp3box.Text);
d4prop=double.Parse(gp4box.Text);
d5prop=double.Parse(gp5box.Text);
d6prop=double.Parse(gp6box.Text);
d7prop=double.Parse(gp7box.Text);
d8prop=double.Parse(gp8box.Text);
d9prop=double.Parse(gp9box.Text);
// new array to deal with suspended sediment MJ 09/05/05
isSuspended = new bool[G_MAX+1];
isSuspended[1] = suspGS1box.Checked;
isSuspended[2] = suspGS2box.Checked;
isSuspended[3] = suspGS3box.Checked;
isSuspended[4] = suspGS4box.Checked;
isSuspended[5] = suspGS5box.Checked;
isSuspended[6] = suspGS6box.Checked;
isSuspended[7] = suspGS7box.Checked;
isSuspended[8] = suspGS8box.Checked;
isSuspended[9] = suspGS9box.Checked;
// new array to deal with suspended sediment MJ 09/05/05
fallVelocity = new double[G_MAX+1];
fallVelocity[1] = double.Parse(fallGS1box.Text);
fallVelocity[2] = double.Parse(fallGS2box.Text);
fallVelocity[3] = double.Parse(fallGS3box.Text);
fallVelocity[4] = double.Parse(fallGS4box.Text);
fallVelocity[5] = double.Parse(fallGS5box.Text);
fallVelocity[6] = double.Parse(fallGS6box.Text);
fallVelocity[7] = double.Parse(fallGS7box.Text);
fallVelocity[8] = double.Parse(fallGS8box.Text);
fallVelocity[9] = double.Parse(fallGS9box.Text);
input_time_step=int.Parse(input_time_step_box.Text);
init_discharge=double.Parse(textBox2.Text);
SW=int.Parse(textBox3.Text);
inpoints=new int[10,2];
// then intiailise the main arrays
if(inbox1.Checked)
{
number_of_points++;
inpoints[0,0]=int.Parse(xbox1.Text);
inpoints[0,1]=int.Parse(ybox1.Text);
}
if(inbox2.Checked)
{
number_of_points++;
inpoints[1,0]=int.Parse(xbox2.Text);
inpoints[1,1]=int.Parse(ybox2.Text);
}
if(inbox3.Checked)
{
number_of_points++;
inpoints[2,0]=int.Parse(xbox3.Text);
inpoints[2,1]=int.Parse(ybox3.Text);
}
if(inbox4.Checked)
{
number_of_points++;
inpoints[3,0]=int.Parse(xbox4.Text);
inpoints[3,1]=int.Parse(ybox4.Text);
}
if(inbox5.Checked)
{
number_of_points++;
inpoints[4,0]=int.Parse(xbox5.Text);
inpoints[4,1]=int.Parse(ybox5.Text);
}
if(inbox6.Checked)
{
number_of_points++;
inpoints[5,0]=int.Parse(xbox6.Text);
inpoints[5,1]=int.Parse(ybox6.Text);
}
if(inbox7.Checked)
{
number_of_points++;
inpoints[6,0]=int.Parse(xbox7.Text);
inpoints[6,1]=int.Parse(ybox7.Text);
}
if(inbox8.Checked)
{
number_of_points++;
inpoints[7,0]=int.Parse(xbox8.Text);
inpoints[7,1]=int.Parse(ybox8.Text);
}
inputfile = new double[number_of_points,((maxcycle-((int)(cycle/60)))/(input_time_step/60))+1000,16];
elev = new double[xmax+2,ymax+2];
discharge = new double[xmax+2,ymax+2];
water_depth = new double[xmax+2,ymax+2];
water_depth2 = new double[xmax+2,ymax+2];
temp_depth = new double[xmax+2,ymax+2];
area = new double[xmax+2,ymax+2];
index = new int[xmax+2,ymax+2];
bedrock = new double[xmax+2,ymax+2];
tempcreep = new double[xmax+2,ymax+2];
init_elevs = new double[xmax+2,ymax+2];
max_flow= new double[xmax+2,ymax+2,9];
flow_dir=new int[xmax+2,ymax+2,2];
strata=new double[(xmax*ymax)/LIMIT,10,G_MAX+1,TRACERS];
grain=new double[(xmax*ymax)/LIMIT,G_MAX+1,TRACERS];
temp=new double[(xmax*ymax)/LIMIT,G_MAX+1,TRACERS];
dist=new double[9,G_MAX+1];
extra_elev=new double[(xmax*ymax)/LIMIT];
cross_scan=new int[xmax+2,ymax+2];
down_scan=new int[ymax+2,xmax+2];
hourly_rain_data=new double[(maxcycle-((int)(cycle/60)))+1000];
bedrock_depth=new double[ymax+5];
climate_data=new double[10001,3];
minesites=new int[1001,2];
temp_grain=new double[G_MAX+1];
veg=new Double[xmax+1,ymax+1,4]; // 0 is elevation, 1 is level of veg cover (ranging from 0 to 1)
edge=new double[xmax+1,ymax+1]; // TJC 27/1/05
edge2=new double[xmax+1,ymax+1]; // TJC 27/4/06
lat_vol = new double[xmax+2,ymax+2]; // tjc
Tau = new double[xmax+2,ymax+2];
old_water_depth = new double[xmax+2,ymax+2];
width = new int[xmax+2,ymax+2];
pool_depth = new double[xmax+2,ymax+2];
qcounter = new int[xmax+2,ymax+2];
left_in = new double[xmax+2,ymax+2];
left_out = new double[xmax+2,ymax+2];
right_in= new double[xmax+2,ymax+2];
right_out = new double[xmax+2,ymax+2];
up_in= new double[xmax+2,ymax+2];
up_out = new double[xmax+2,ymax+2];
down_in= new double[xmax+2,ymax+2];
down_out = new double[xmax+2,ymax+2];
dischargeinput=new double[1000,5];
tracerinput=new double[1000,5];
hydrograph=new double[(maxcycle-((int)(cycle/60)))+1000,2];
tracerhydrograph=new double[(maxcycle-((int)(cycle/60)))+1000,2];
// MJ arrays 08/02/05
tempsusp = new double[xmax+2,ymax+2,G_MAX+1,TRACERS];
tempsusptot = new double[xmax+2,ymax+2];
Vsusp = new double[xmax+2,ymax+2,G_MAX+1,TRACERS];
Vsusptot = new double[xmax+2,ymax+2];
Csusptot = new double[xmax+2,ymax+2];
// JOE arrays
flow_velocity = new double[xmax+2,ymax+2,10]; //
soil_saturation = new double[xmax+2,ymax+2]; //
slopeAnalysis = new double[xmax+2,ymax+2]; //
aspect = new double[xmax+2,ymax+2]; //
hillshade = new double[xmax+2,ymax+2]; //
//Gez arrays
sum_grain = new double[G_MAX+1];
old_sum_grain = new double[G_MAX+1];
Qg_step = new double[G_MAX+1];
Qg_hour = new double[G_MAX+1];
Qg_over = new double[G_MAX+1];
Qg_last = new double[G_MAX+1];
CATCH_FILE = TimeseriesOutBox.Text; // MJ 18/01/05
}
void sort_active2(int x,int y)
{
int xyindex;
double total;
double amount;
double coeff;
int n,z,p;
if (index[x,y] == -9999) addGS(x,y); // should not be necessary
xyindex = index[x,y];
total = 0.0;
for (n=0;n<=G_MAX;n++)
{
for (p=0;p<=(TRACERS-1);p++)
{
total += grain[xyindex,n,p];
}
}
if (total > 0.3) // depositing - create new strata layer and remove bottom one..
{
// start from bottom
// remove bottom active layer
// then move all from layer above into one below, up to the top layer
for(z=9;z>=1;z--)
{
for(n=0;n<=G_MAX-2;n++)
{
for (p=0;p<=(TRACERS-1);p++)
{
strata[xyindex,z,n,p]=strata[xyindex,z-1,n,p];
}
}
}
// then remove strata thickness from grain - and add to top strata layer
coeff = active / total;
for (n=1;n<=(G_MAX-1);n++)
{
if ((grain_tot(xyindex,n) > 0.0))
{
for (p=0;p<=(TRACERS-1);p++)
{
amount = coeff * (grain[xyindex,n,p]);
strata[xyindex,0,n-1,p] = amount;
grain[xyindex,n,p] -= amount;
}
}
}
}
if (total < 0.05) // eroding - eat into existing strata layer & create new one at bottom
{
// Start at top
// Add top strata to grain
for (n=1;n<=(G_MAX-1);n++)
{
for (p=0;p<=(TRACERS-1);p++)
{
grain[xyindex,n,p] += strata[xyindex,0,n-1,p];
}
}
// then from top down add lower strata into upper
for(z=0;z<=8;z++)
{
for(n=0;n<=G_MAX-2;n++)
{
for (p=0;p<=(TRACERS-1);p++)
{
strata[xyindex,z,n,p] = strata[xyindex,z+1,n,p];
}
}
}
// add new layer at the bottom
amount = active;
p = 0;
z = 9;
strata[xyindex,z,0,p] = amount*d1prop; // 0.0;
strata[xyindex,z,1,p] = amount*d2prop; // + amount*d1prop;
strata[xyindex,z,2,p] = amount*d3prop;
strata[xyindex,z,3,p] = amount*d4prop;
strata[xyindex,z,4,p] = amount*d5prop;
strata[xyindex,z,5,p] = amount*d6prop;
strata[xyindex,z,6,p] = amount*d7prop;
strata[xyindex,z,7,p] = amount*d8prop;
strata[xyindex,z,8,p] = amount*d9prop;
}
}
void sort_active(int x,int y)
{
sort_active2(x,y);
}
double Fi(int index1, int t)
{
int n,z;
double active_thickness=0;
double total=0;
for(n=1;n<=G_MAX;n++)
{
for(z=0;z<=(TRACERS-1);z++)
{
active_thickness+=(grain[index1,n,z]);
}
}
for(z=0;z<=(TRACERS-1);z++)
{
total+=(grain[index1,t,z]);
}
if(active_thickness<0.0001)
{
return(0.0);
}
else
{
return(total/active_thickness);
}
}
double sand_fraction(int index1)
{
int n,z;
double active_thickness=0;
double sand_total=0;
for(n=1;n<=G_MAX;n++)
{
for(z=0;z<=(TRACERS-1);z++)
{
active_thickness+=(grain[index1,n,z]);
}
}
for(n=1;n<=2;n++) // number of sand fractions...
{
for(z=0;z<=(TRACERS-1);z++)
{
sand_total+=(grain[index1,n,z]);
}
}
if(active_thickness<0.0001)
{
return(0.0);
}
else
{
return(sand_total/active_thickness);
}
}
double d50(int index1)
{
int z,n,i;
double active_thickness=0;
double Dfifty=0,max=0,min=0;
double[] cum_tot;
cum_tot = new double[20];
for(n=1;n<=G_MAX;n++)
{
for(z=0;z<=(TRACERS-1);z++)
{
active_thickness+=(grain[index1,n,z]);
cum_tot[n]+=active_thickness;
}
}
i=1;
while(cum_tot[i]<(active_thickness*0.5)&&i<=9)
{
i++;
}
if(i==1){min=Math.Log(d1);max=Math.Log(d1);}
if(i==2){min=Math.Log(d1);max=Math.Log(d2);}
if(i==3){min=Math.Log(d2);max=Math.Log(d3);}
if(i==4){min=Math.Log(d3);max=Math.Log(d4);}
if(i==5){min=Math.Log(d4);max=Math.Log(d5);}
if(i==6){min=Math.Log(d5);max=Math.Log(d6);}
if(i==7){min=Math.Log(d6);max=Math.Log(d7);}
if(i==8){min=Math.Log(d7);max=Math.Log(d8);}
if(i==9){min=Math.Log(d8);max=Math.Log(d9);}
//if(i==9){min=Math.Log(d8);max=Math.Log(d9);}
Dfifty=Math.Exp(min+((max-min)*((cum_tot[i]-(active_thickness*0.5))/(cum_tot[i]-cum_tot[i-1]))));
if(active_thickness<0.0000001)Dfifty=0;
return Dfifty;
}
double mean_ws_slope(int x, int y)
{
double slopesum=0;
int slopenum=0;
double wd=water_depth_erosion_threshold;
if(water_depth[x-1,y]>wd&&water_depth[x+1,y]>wd)
{
slopesum+=Math.Abs(((elev[x-1,y]+water_depth[x-1,y])-(elev[x+1,y]+water_depth[x+1,y]))/(DX*2));
slopenum++;
}
if(water_depth[x,y-1]>wd&&water_depth[x,y+1]>wd)
{
slopesum+=Math.Abs(((elev[x,y-1]+water_depth[x,y-1])-(elev[x,y+1]+water_depth[x,y+1]))/(DX*2));
slopenum++;
}
if(water_depth[x-1,y-1]>wd&&water_depth[x+1,y+1]>wd)
{
slopesum+=Math.Abs(((elev[x-1,y-1]+water_depth[x-1,y-1])-(elev[x+1,y+1]+water_depth[x+1,y+1]))/(root*2));
slopenum++;
}
if(water_depth[x-1,y+1]>wd&&water_depth[x+1,y-1]>wd)
{
slopesum+=Math.Abs(((elev[x-1,y+1]+water_depth[x-1,y+1])-(elev[x+1,y-1]+water_depth[x+1,y-1]))/(root*2));
slopenum++;
}
if(slopenum<1)slopenum=1;
//if(slopesum==0)slopesum=mean_old_ws_slope(x,y);
return(slopesum/slopenum);
}
double mean_old_ws_slope(int x, int y)
{
double slopesum=0;
int slopenum=0;
double wd=water_depth_erosion_threshold;
if(old_water_depth[x-1,y]>wd&&old_water_depth[x+1,y]>wd)
{
slopesum+=Math.Abs(((elev[x-1,y]+old_water_depth[x-1,y])-(elev[x+1,y]+old_water_depth[x+1,y]))/(DX*2));
slopenum++;
}
if(old_water_depth[x,y-1]>wd&&old_water_depth[x,y+1]>wd)
{
slopesum+=Math.Abs(((elev[x,y-1]+old_water_depth[x,y-1])-(elev[x,y+1]+old_water_depth[x,y+1]))/(DX*2));
slopenum++;
}
if(old_water_depth[x-1,y-1]>wd&&old_water_depth[x+1,y+1]>wd)
{
slopesum+=Math.Abs(((elev[x-1,y-1]+old_water_depth[x-1,y-1])-(elev[x+1,y+1]+old_water_depth[x+1,y+1]))/(root*2));
slopenum++;
}
if(old_water_depth[x-1,y+1]>wd&&old_water_depth[x+1,y-1]>wd)
{
slopesum+=Math.Abs(((elev[x-1,y+1]+old_water_depth[x-1,y+1])-(elev[x+1,y-1]+old_water_depth[x+1,y-1]))/(root*2));
slopenum++;
}
if(slopenum<1)slopenum=1;
//if(slopesum==0)slopesum=mean_old_ws_slope2(x,y);
return(slopesum/slopenum);
}
double mean_ws_slope2(int x, int y) //
{
int x2,y2,dir;
double tempelev=0;//(water_depth[x,y]+elev[x,y]);
int tempinc=0;
double wd=water_depth_erosion_threshold;
for (dir=1;dir<=8;dir++)
{
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if(water_depth[x2,y2]>wd)
{
if((water_depth[x,y]+elev[x,y])>(water_depth[x2,y2]+elev[x2,y2]))
{
tempelev+=((water_depth[x,y]+elev[x,y])-(water_depth[x2,y2]+elev[x2,y2]))/DX;
tempinc++;
}
}
}
if(tempinc<1)tempinc=1;
return(tempelev/tempinc);
}
double mean_old_ws_slope2(int x, int y) //
{
int x2,y2,dir;
double tempelev=0;//(water_depth[x,y]+elev[x,y]);
int tempinc=0;
double wd=water_depth_erosion_threshold;
for (dir=1;dir<=8;dir++)
{
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if(old_water_depth[x2,y2]>wd)
{
if((old_water_depth[x,y]+elev[x,y])>(old_water_depth[x2,y2]+elev[x2,y2]))
{
tempelev+=((old_water_depth[x,y]+elev[x,y])-(old_water_depth[x2,y2]+elev[x2,y2]))/DX;
tempinc++;
}
}
}
if(tempinc<1)tempinc=1;
return(tempelev/tempinc);
}
double max_ws_slope(int x, int y)
{
double slopemax=0;
double slopesum=0;
double wd=water_depth_erosion_threshold;
if(water_depth[x-1,y]>wd&&water_depth[x+1,y]>wd)
{
slopesum=Math.Abs(((elev[x-1,y]+water_depth[x-1,y])-(elev[x+1,y]+water_depth[x+1,y]))/(DX*2));
if(slopesum>slopemax)slopemax=slopesum;
}
if(water_depth[x,y-1]>wd&&water_depth[x,y+1]>wd)
{
slopesum=Math.Abs(((elev[x,y-1]+water_depth[x,y-1])-(elev[x,y+1]+water_depth[x,y+1]))/(DX*2));
if(slopesum>slopemax)slopemax=slopesum;
}
if(water_depth[x-1,y-1]>wd&&water_depth[x+1,y+1]>wd)
{
slopesum=Math.Abs(((elev[x-1,y-1]+water_depth[x-1,y-1])-(elev[x+1,y+1]+water_depth[x+1,y+1]))/(root*2));
if(slopesum>slopemax)slopemax=slopesum;
}
if(water_depth[x-1,y+1]>wd&&water_depth[x+1,y-1]>wd)
{
slopesum=Math.Abs(((elev[x-1,y+1]+water_depth[x-1,y+1])-(elev[x+1,y-1]+water_depth[x+1,y-1]))/(root*2));
if(slopesum>slopemax)slopemax=slopesum;
}
return(slopemax);
}
double max_bed_slope(int x, int y)
{
double slope=0;
int slopetot=0;
double slopemax=0;
if(elev[x,y]>elev[x,y-1])
{
slope=Math.Pow((elev[x,y]-elev[x,y-1])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x+1,y-1])
{
slope=Math.Pow((elev[x,y]-elev[x+1,y-1])/DX,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x+1,y])
{
slope=Math.Pow((elev[x,y]-elev[x+1,y])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x+1,y+1])
{
slope=Math.Pow((elev[x,y]-elev[x+1,y+1])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x,y+1])
{
slope=Math.Pow((elev[x,y]-elev[x,y+1])/DX,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x-1,y+1])
{
slope=Math.Pow((elev[x,y]-elev[x-1,y+1])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x-1,y])
{
slope=Math.Pow((elev[x,y]-elev[x-1,y])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x-1,y-1])
{
slope=Math.Pow((elev[x,y]-elev[x-1,y-1])/DX,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(slope>0)slope=(slope/slopetot);
//return(slopemax);
//if(slopemax<0.001)slopemax=0.001;
return(slopemax);
}
double max_neg_bed_slope(int x, int y)
{
double slope = 0;
int slopetot = 0;
double slopemax = 0;
if (elev[x, y] < elev[x, y - 1])
{
slope = Math.Pow((elev[x, y-1] - elev[x, y ]) / root, 1);
if (slope > slopemax) slopemax += slope;
slopetot++;
}
//if (elev[x, y] < elev[x + 1, y - 1])
//{
// slope = Math.Pow((elev[x+1, y-1] - elev[x, y]) / DX, 1);
// if (slope > slopemax) slopemax = slope;
// slopetot++;
//}
if (elev[x, y] < elev[x + 1, y])
{
slope = Math.Pow((elev[x+1, y] - elev[x, y]) / root, 1);
if (slope > slopemax) slopemax += slope;
slopetot++;
}
//if (elev[x, y] < elev[x + 1, y + 1])
//{
// slope = Math.Pow((elev[x+1, y+1] - elev[x, y ]) / root, 1);
// if (slope > slopemax) slopemax = slope;
// slopetot++;
//}
if (elev[x, y] < elev[x, y + 1])
{
slope = Math.Pow((elev[x, y+1] - elev[x, y]) / DX, 1);
if (slope > slopemax) slopemax += slope;
slopetot++;
}
//if (elev[x, y] < elev[x - 1, y + 1])
//{
// slope = Math.Pow((elev[x-1, y+1] - elev[x, y]) / root, 1);
// if (slope > slopemax) slopemax = slope;
// slopetot++;
//}
if (elev[x, y] < elev[x - 1, y])
{
slope = Math.Pow((elev[x-1, y] - elev[x, y]) / root, 1);
if (slope > slopemax) slopemax += slope;
slopetot++;
}
//if (elev[x-1, y-1] > elev[x - 1, y - 1])
//{
// slope = Math.Pow((elev[x-1, y-1] - elev[x, y]) / DX, 1);
// if (slope > slopemax) slopemax = slope;
// slopetot++;
//}
//if (slope < 0) slope = (slope / slopetot);
//return(slopemax);
//if(slopemax<0.001)slopemax=0.001;
return (slopemax);
}
double mean_bed_slope(int x, int y)
{
double slope=0;
int slopetot=0;
double slopemax=0;
if(elev[x,y]>elev[x,y-1])
{
slope=Math.Pow((elev[x,y]-elev[x,y-1])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x+1,y-1])
{
slope=Math.Pow((elev[x,y]-elev[x+1,y-1])/DX,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x+1,y])
{
slope=Math.Pow((elev[x,y]-elev[x+1,y])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x+1,y+1])
{
slope=Math.Pow((elev[x,y]-elev[x+1,y+1])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x,y+1])
{
slope=Math.Pow((elev[x,y]-elev[x,y+1])/DX,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x-1,y+1])
{
slope=Math.Pow((elev[x,y]-elev[x-1,y+1])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x-1,y])
{
slope=Math.Pow((elev[x,y]-elev[x-1,y])/root,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(elev[x,y]>elev[x-1,y-1])
{
slope=Math.Pow((elev[x,y]-elev[x-1,y-1])/DX,1);
if(slope>slopemax)slopemax=slope;
slopetot++;
}
if(slope>0)slope=(slope/slopetot);
//if(slope<0.001)slope=0.01;
return(slope);
}
double grain_tot(int cent,int fract)
{
int n;
double total=0;
//if(cent==-9999)return total;
for(n=0;n<=(TRACERS-1);n++)
{
total+=grain[cent,fract,n];
}
return total;
}
double temp_tot(int cent,int fract)
{
int n;
double total=0;
for(n=0;n<=(TRACERS-1);n++)
{
total+=temp[cent,fract,n];
}
return total;
}
double strata_tot(int cent,int z,int fract)
{
int n;
double total=0;
for(n=0;n<=(TRACERS-1);n++)
{
total+=strata[cent,z,fract,n];
}
return total;
}
void addGS(int x,int y)
{
int n,z,q;
grain_array_tot++;
index[x,y]=grain_array_tot;
for(n=0;n<=G_MAX;n++)temp[grain_array_tot,n,0]=0;
z=0;
/*if(x>203&&x<430&&y>24&&y<101)z=1;*/
if(grassbox.Checked==true)
{
veg[x,y,0]=elev[x,y]; //elev
veg[x,y,1]=1; // proportion
veg[x,y,2]=0.3;
veg[x,y,3]=0.1;
}
// if(grassbox.Checked==true)
// {
// grain[grain_array_tot,0,z]=0;
// grain[grain_array_tot,1,z]=active;
// grain[grain_array_tot,2,z]=0;//+(active*d1prop);
// grain[grain_array_tot,3,z]=0;
// grain[grain_array_tot,4,z]=0;
// grain[grain_array_tot,5,z]=0;
// grain[grain_array_tot,6,z]=0;
// grain[grain_array_tot,7,z]=0;
// grain[grain_array_tot,8,z]=0;
// grain[grain_array_tot,9,z]=0;
// grain[grain_array_tot,10,z]=0;
//
//
// for(n=0;n<=9;n++)
// {
// strata[grain_array_tot,n,0,z]=(active); // TJ xx/03/05
// strata[grain_array_tot,n,1,z]=0;//+(active*d1prop); // TJ xx/03/05
// strata[grain_array_tot,n,2,z]=0;
// strata[grain_array_tot,n,3,z]=0;
// strata[grain_array_tot,n,4,z]=0;
// strata[grain_array_tot,n,5,z]=0;
// strata[grain_array_tot,n,6,z]=0;
// strata[grain_array_tot,n,7,z]=0;
// strata[grain_array_tot,n,8,z]=0;
//
// if(elev[x,y]-(active*(n+1))<(bedrock[x,y]-active))
// {
// for(q=0;q<=(G_MAX-2);q++)
// {
// strata[grain_array_tot,n,q,z]=0;
// }
// }
// }
// }
//if(grassbox.Checked==false)
{
grain[grain_array_tot,0,z]=0;
grain[grain_array_tot,1,z]=active*d1prop;
grain[grain_array_tot,2,z]=active*d2prop;//+(active*d1prop);
grain[grain_array_tot,3,z]=active*d3prop;
grain[grain_array_tot,4,z]=active*d4prop;
grain[grain_array_tot,5,z]=active*d5prop;
grain[grain_array_tot,6,z]=active*d6prop;
grain[grain_array_tot,7,z]=active*d7prop;
grain[grain_array_tot,8,z]=active*d8prop;
grain[grain_array_tot,9,z]=active*d9prop;
grain[grain_array_tot,10,z]=0;
for(n=0;n<=9;n++)
{
strata[grain_array_tot,n,0,z]=(active)*d1prop; // TJ xx/03/05
strata[grain_array_tot,n,1,z]=(active*d2prop);//+(active*d1prop); // TJ xx/03/05
strata[grain_array_tot,n,2,z]=(active)*d3prop;
strata[grain_array_tot,n,3,z]=(active)*d4prop;
strata[grain_array_tot,n,4,z]=(active)*d5prop;
strata[grain_array_tot,n,5,z]=(active)*d6prop;
strata[grain_array_tot,n,6,z]=(active)*d7prop;
strata[grain_array_tot,n,7,z]=(active)*d8prop;
strata[grain_array_tot,n,8,z]=(active)*d9prop;
if(elev[x,y]-(active*(n+1))<(bedrock[x,y]-active))
{
for(q=0;q<=(G_MAX-2);q++)
{
strata[grain_array_tot,n,q,z]=0;
}
}
}
}
sort_active(x,y);
}
// calc roughtness on Srickler relationship
double strickler(int x, int y)
{
double temp=0;
double temp_d50=1;
if (index[x,y] != -9999)temp_d50=d50(index[x,y]);
temp =0.034*Math.Pow(temp_d50,0.167);
//Console.WriteLine(Convert.ToString(strickler(x,y)));
temp+=0.012;
return temp;
}
//Calculate roughness - Added JMW 20051122
//Based on Baptist, 2005
double chezy(int x, int y)
{
double Cr;
double Cb;
double temp_d50=30;
double temp_depth=old_water_depth[x,y];
if(temp_depth<=0)temp_depth=0.1;
// just to save it when there is no grain file
if (index[x,y] != -9999)temp_d50=d50(index[x,y]);
// Grain roughness (strickler formulation)
Cb = (26.4*Math.Pow(temp_depth/temp_d50,0.167));
Cr=Cb;
if (veg[x,y,1]>0.01)// if there is any veg..
{
// Applying vegetation
if (veg[x,y,3] < temp_depth)
{
Cr = (Math.Pow(1/(1/(Cb*Cb) + veg[x,y,2]*veg[x,y,3]/(2*g)),0.5)
+ Math.Pow(g,0.5)/kappa*Math.Log(temp_depth/veg[x,y,3]));
}
else
{
Cr = (Math.Pow(1/(1/(Cb*Cb) + veg[x,y,2]*temp_depth/(2*g)),0.5));
}
}
return Cr;
}
double chezytomanning(double chezyc, double depth)
{
return (Math.Pow(depth,0.167))/chezyc;
}
double calc_manning(int x, int y)
{
double temp_depth=old_water_depth[x,y];
if(temp_depth<=0)temp_depth=0.1;
return chezytomanning(chezy(x,y), temp_depth)+0.012;
}
void grow_grass(double amount3)
{
int x, y;
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
// check if veg below elev! if so raise to elev
if(water_depth[x,y]1)veg[x,y,1]=1;
}
// trying to see now, if veg is above elev - so if lateral erosion happens - more than 0.1m the veg gets wiped..
if(veg[x,y,1]>0)
{
if(veg[x,y,0]-elev[x,y]>0.1)veg[x,y,1]=0;
}
// now see if veg under water - if so let it die back a bit..
if(water_depth[x,y]>=water_depth_erosion_threshold&&veg[x,y,1]>0)
{
veg[x,y,1]-=(amount3*2);
if(veg[x,y,1]<0)veg[x,y,1]=0;
}
}
}
// /****** this has to have its own version of sort active not removing grass ***/
//
//
// int x,y,n,z,temp_centre,q,p;
// double total,total2,sub_tot;
// //double amount3=0.000961;
// double amount2;
// double amount=0;
//
// for(x=1;x<=xmax;x++)
// {
// for(y=1;y<=ymax;y++)
// {
// if(index[x,y]!=-9999&&water_depth[x,y]<=MIN_Q)
// {
//
//
// /** 0.000057 is adding grass to 0.1 at ten hourly steps
// so its 0.01 from 0 in 2 years **/
//
// // if((grain[index[x,y],0,0]+amount3)>active)amount3=active-grain[index[x,y],0,0];
// // grain[index[x,y],0,0]+=amount3;
// // sort_active(x,y);
// // }
// // }
// // }
// // }
//
//
//
// sort_active(x,y);
//
// grain[index[x,y],0,0]+=amount3;
// if(grain[index[x,y],0,0]>active)grain[index[x,y],0,0]=active;
//
// temp_centre=index[x,y];
// /** has to run from n=1 */
//
// //total=active+amount3;
// amount=amount3;
// //if(amount<0)printf("asdasd %f\n",(amount*1000000));
// // doing the bedrock..
// if(grain[temp_centre,G_MAX,0]>0)
// {
// if((grain[temp_centre,G_MAX,0]+amount)>active)
// {
// amount=active-grain[temp_centre,G_MAX,0];
// }
//
// }
//
// total=0;
// for(n=1;n<=G_MAX-1;n++)
// {
// for(q=0;q<=(TRACERS-1);q++)
// {
//
// total+=grain[temp_centre,n,q];
// }
// }
//
// for(n=1;n<=(G_MAX-1);n++)
// {
// if(grain_tot(temp_centre,n)>0)
// {
// amount2=(grain_tot(temp_centre,n)/total)*amount;
// if(n>0&&n0)
// {
// for(q=0;q<=(TRACERS-1);q++)
// {
// strata[temp_centre,0,n-1,q]+=amount2*(grain[temp_centre,n,q]/sub_tot);
// }
// }
// }
// sub_tot=grain_tot(temp_centre,n);
// if(sub_tot>0)
// {
// for(q=0;q<=(TRACERS-1);q++)
// {
// grain[temp_centre,n,q]-=amount2*(grain[temp_centre,n,q]/sub_tot);
// }
// }
// }
// }
//
// /* then workk down through the strata **/
//
// for(z=0;z<=9;z++)
// {
// total2=0;
// for(n=0;n<=(G_MAX-2);n++)total2+=strata_tot(temp_centre,z,n);
// amount=(total2-(active));
// for(n=0;n<=(G_MAX-2);n++)
// {
// if(strata_tot(temp_centre,z,n)>0&&amount>0)
// {
// if(z<9)
// {
// sub_tot=strata_tot(temp_centre,z,n);
// for(q=0;q<=(TRACERS-1);q++)
// {
// strata[temp_centre,z+1,n,q]+=(strata[temp_centre,z,n,q]/sub_tot)*((sub_tot/total2)*amount);
// }
// }
// sub_tot=strata_tot(temp_centre,z,n);
// for(q=0;q<=(TRACERS-1);q++)
// {
// strata[temp_centre,z,n,q]-=(strata[temp_centre,z,n,q]/sub_tot)*((sub_tot/total2)*amount);
// }
// }
// }
// }
//
//
//
//
// sort_active(x,y);
//
// }
// }
// }
}
void creep(double time)
{
/** creep rate is 10*-2 * slope per year, so inputs time jump in years*/
/** very important differnece here is that slide_GS() is called only if
BOTH cells are not -9999 therfore if both have grainsize then do additions.
this is to stop the progressive spread of selected cells upslope */
int x,y;
double temp;
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
tempcreep[x,y]=0;
}
}
for(x=2;xbedrock[x,y])
{
if(elev[x,y-1]0)
{
temp=((elev[x,y]-elev[x,y-1])/DX)*CREEP_RATE*time/DX;
if((elev[x,y]-temp)0)
{
temp=((elev[x,y]-elev[x+1,y-1])/root)*CREEP_RATE*time/root;
if((elev[x,y]-temp)0)
{
temp=((elev[x,y]-elev[x+1,y])/DX)*CREEP_RATE*time/DX;
if((elev[x,y]-temp)0)
{
temp=((elev[x,y]-elev[x+1,y+1])/root)*CREEP_RATE*time/root;
if((elev[x,y]-temp)0)
{
temp=((elev[x,y]-elev[x,y+1])/DX)*CREEP_RATE*time/DX;
if((elev[x,y]-temp)0)
{
temp=((elev[x,y]-elev[x-1,y+1])/root)*CREEP_RATE*time/root;
if((elev[x,y]-temp)0)
{
temp=((elev[x,y]-elev[x-1,y])/DX)*CREEP_RATE*time/DX;
if((elev[x,y]-temp)0)
{
temp=((elev[x,y]-elev[x-1,y-1])/root)*CREEP_RATE*time/root;
if((elev[x,y]-temp)area[x,y])area[x,y]=water_depth[x,y];
if(elev[x+1,y-1]1;x--)
{
for(y=1;yarea[x,y])area[x,y]=water_depth[x,y];
if(elev[x-1,y-1]1;y--)
{
for(x=1;xarea[x,y])area[x,y]=water_depth[x,y];
if(elev[x-1,y-1]area[x,y])area[x,y]=water_depth[x,y];
if(elev[x-1,y+1] 0) water_depth[x, y] += pool_depth[x, y]; } }
}
}
/*******************************/
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
cross_scan[x,y]=0;
down_scan[y,x]=0;
if(water_depth[x,y]==-9999)water_depth[x,y]=0;
}
}
for(x=1;(x<=xmax);x++)
{
for(y=1;y<=(ymax);y++)
{
tempxmin=-3;
tempxmax=3;
tempymin=-3;
tempymax=3;
while(x+tempxmin<1)tempxmin++;
while(x+tempxmax>xmax)tempxmax--;
while(y+tempymin<1)tempymin++;
while(y+tempymax>ymax)tempymax--;
waterflag=FALSE;
for(x1=tempxmin;x1<=tempxmax;x1++)
{
for(y1=tempymin;y1<=tempymax;y1++)
{
if(water_depth[x+x1,y+y1]>=w)
{
waterflag=TRUE;
}
}
}
if(waterflag==FALSE)
water_depth[x,y]=-9999;
if(elev[x,y]==-9999)water_depth[x,y]=-9999;
}
}
for(x=1;x<=xmax;x++)
{
inc=1;
for(y=1;y<=ymax;y++)
{
discharge[x,y]=0;
max_flow[x,y,0]=0;
water_depth2[x,y]=0;
if(water_depth[x,y]>-9999)
{
cross_scan[x,inc]=y;
inc++;
}
//discharge[x,y]=0;
}
}
for(y=1;y<=ymax;y++)
{
inc=1;
for(x=xmax;x>=1;x--)
{
if(water_depth[x,y]>-9999)
{
down_scan[y,inc]=x;
inc++;
}
//if(input_type_flag==1)discharge[x,y]=0;
}
}
for(y=1;y<=ymax;y++)
{
// line added to remove excess Qw values from far RH column
if(discharge[xmax+1,y]>0)
{
discharge[xmax+1,y]=0;
}
// end of addition
inc=1;
while(down_scan[y,inc]>0)
{
x=down_scan[y,inc];
inc++;
water_depth[x,y]=0;
}
}
j_mean=temp_j_mean;
// //** these lines have been added in attempt to remove discharge spikes MJ 25/01/05
// for(x=1;(x<=xmax);x++)
// {
// for(y=1;y<=(ymax);y++)
// {
// discharge[x,y] = 0.0;
// }
// }
//
// for(int ccc=1;ccc<=5*init_route_number_of_scans;ccc++)
// {
// if(input_type_flag==0)
// {
// // if the input type flag is 0 then the discharge inputs are from points
// j_mean=0;
// double totqtemp=0;
// for(n=0;n<=number_of_points-1;n++)
// {
// totqtemp+=inputfile[n,(int)((cycle-init_cycle)/input_time_step),1];
// }
//
// if(totqtemp>init_discharge)
// {
// init_discharge=init_discharge*2;
// if(init_discharge80)
// {
// init_discharge=init_discharge/2;
// Console.Write(" scanning down ");
// init_route(TRUE,init_discharge);
// time_factor=0.0000000001;
// }
//
// for(n=0;n<=number_of_points-1;n++)
// {
// x=inpoints[n,0];
// y=inpoints[n,1];
// discharge[x,y]+=inputfile[n,(int)((cycle-init_cycle)/input_time_step),1];
// }
// }
//
// else if(input_type_flag==1)
// {
// // if the input type flag is 1 then the discharge is input from the hydrograph...
// if(cycle>=time_1)
// {
// do
// {
// time_1+=2;
// calc_J(time_1);
// if(time_factor>3600&&new_j_mean>(0.2/3000000))
// {
// cycle=time_1+60;
// time_factor=3600;
// }
// }while(time_1=baseflow)
// {
// baseflow=baseflow*2;
// Console.Write("goig up.. \n");
// get_area();
// init_route(TRUE,baseflow);
// time_factor=0.0000000001;
// }
//
//
// if(baseflow>(j_mean*2)&&baseflow>0.0000005)
// {
// baseflow=j_mean*1.01;
// Console.Write("going down.. \n");
// get_area();
// init_route(TRUE,baseflow);
// time_factor=0.0000000001;
// }
//
// //discharge[20,300]+=j_mean*10000000; commented out, if entered allows flow to be entered at a point as well.
// }
//
// route_lr();
// route_up();
// route_rl();
// route_down(cycle);
// route_rl();
// route_up();
// route_lr();
// route_down(cycle);
// }
// for(y=1;y<=ymax;y++)
// {
// discharge[xmax+1,y]=0;
// }
//
// //** end of discharge spike removal attempt
this.InfoStatusPanel.Text="Running"; // MJ 14/01/05
}
private void calc_width(int x, int y)
{
int z1;
int inside=0;
int outside=0;
if(x<6||x>(xmax-5)||y<6||y>(ymax-5))return;
for(z1=1;z1<=5;z1++)
{
if(edge[x+z1,y]>=0)outside=z1;
if(edge[x+z1,y+z1]>=0)outside=z1;
if(edge[x+z1,y-z1]>=0)outside=z1;
if(edge[x,y-z1]>=0)outside=z1;
if(edge[x,y+z1]>=0)outside=z1;
if(edge[x-z1,y]>=0)outside=z1;
if(edge[x-z1,y+z1]>=0)outside=z1;
if(edge[x-z1,y-z1]>=0)outside=z1;
if(outside>0)z1=5;
}
for(z1=1;z1<=5;z1++)
{
if(edge[x+z1,y]<=0&&edge[x+z1,y]>-9999)inside=z1;
if(edge[x+z1,y+z1]<=0&&edge[x+z1,y+z1]>-9999)inside=z1;
if(edge[x+z1,y-z1]<=0&&edge[x+z1,y-z1]>-9999)inside=z1;
if(edge[x,y-z1]<=0&&edge[x,y-z1]>-9999)inside=z1;
if(edge[x,y+z1]<=0&&edge[x,y+z1]>-9999)inside=z1;
if(edge[x-z1,y]<=0&&edge[x-z1,y]>-9999)inside=z1;
if(edge[x-z1,y+z1]<=0&&edge[x-z1,y+z1]>-9999)inside=z1;
if(edge[x-z1,y-z1]<=0&&edge[x-z1,y-z1]>-9999)inside=z1;
if(inside>0)z1=5;
}
width[x,y]=inside+outside;
}
private void calc_J(double cycle)
{
double local_rain_fall_rate; /** in m/second **/
double local_time_step=120; /** in secs */
old_j_mean=new_j_mean;
jo=j;
local_rain_fall_rate=0;
if(hourly_rain_data[(int)(cycle/60)]>0)
{
local_rain_fall_rate=rain_factor*((hourly_rain_data[(int)(cycle/60)]/1000)/3600); /** divide by 1000 to make m/hr, then by 3600 for m/sec */
}
if (local_rain_fall_rate==0)
{
j=jo/(1+((jo*local_time_step)/M));
new_j_mean=M/local_time_step*Math.Log(1+((jo*local_time_step)/M));
}
if (local_rain_fall_rate>0)
{
j=local_rain_fall_rate/(((local_rain_fall_rate-jo)/jo)*Math.Exp((0-local_rain_fall_rate)*local_time_step/M)+1);
new_j_mean=(M/local_time_step)*Math.Log(((local_rain_fall_rate-jo)+jo*Math.Exp((local_rain_fall_rate*local_time_step)/M))/local_rain_fall_rate);
}
if(new_j_mean<0)new_j_mean=0;
/**printf("new J mean = %f\n",(new_j_mean*1000));*/
}
void route_up()
{
int x,y,inc, n,i;
double slope=0, depth=0,lowest , tot_ht, tot_q, temp_a, q_out, ht;
double manning=0.03;
double factor=1;
double threshold=MIN_Q;
inc=1;
//this.InfoStatusPanel.Text="Up";
for(y=ymax;y>=1;y--)
{
inc=1;
//drawwater(mygraphics);
while(down_scan[y,inc]>0)
{
x=down_scan[y,inc];
inc++;
ht=elev[x,y];
/** inputting water from the edges **/
if(water_depth[x,y+1]==-9999&&water_depth[x,y]!=-99&&y<(ymax-10))
{
/** get slope **/
discharge[x,y]=(area[x,y]*j_mean)*Math.Pow(DX,2);
water_depth[x,y]=-99;
}
else
{
discharge[x,y]+=((j_mean*Math.Pow(DX,2))/8); // 4 to 8 19/01/05
}
/* determine average slope */
if(discharge[x,y]>0.01)
{
slope=max_bed_slope(x,y);
if(slope<0.002)slope=0.002;
threshold=K*slope*DX;
if(thresholddischarge[x,y])depth=discharge[x,y];
/***** depth added if greater than that there. **/
if(depth>water_depth[x,y])
{
water_depth[x,y]=depth;
lat_vol[x,y]=discharge[x,y];
}
}
/* then do surface routing */
if(x>1&&x<(xmax)&&discharge[x,y]>threshold&&water_depth[x-1,y-1]!=-9999&&water_depth[x,y-1]!=-9999&&water_depth[x+1,y-1]!=-9999)
{
tot_q=0;
temp_a=0;
/********* first sort out wet height *****/
/* starting with d/s slopes ****/
discharge[x,y]-=threshold;
/***** now to route discharge d/s ***************/
tot_ht=elev[x,y]+depth;
//
// start of main routing bit
//
if(elev[x,y-1]elev[x,y]&&
elev[x,y-1]>elev[x,y]&&
elev[x+1,y-1]>elev[x,y])
{
if(elev[x-1,y-1]discharge[x,y])q_out=0; // line to prevent very very small depths increasing q_out disproportionaltely
if(lowest>tot_ht)q_out=0;
}
n=x;
while((x-n)elev[n-1,y-1]&&(n-1)>0&&water_depth[n-1,y-1]!=-9999)//&&q_out>lat_vol[n-1,y-1])
{
tot_q+=Math.Pow(((tot_ht-elev[n-1,y-1])/root),fexp);
n--;
}
if(tot_ht>elev[x,y-1]&&water_depth[x,y-1]!=-9999)
{
tot_q+=Math.Pow(((tot_ht-elev[x,y-1])/DX),fexp);
}
n=x;
while((n-x)elev[n+1,y-1]&&(n+1)lat_vol[n+1,y-1])
{
tot_q+=Math.Pow(((tot_ht-elev[n+1,y-1])/root),fexp);
n++;
}
n=x;
double tt=0; // temp variable
while((x-n)elev[n-1,y-1]&&(n-1)>0&&water_depth[n-1,y-1]!=-9999)//&&q_out>lat_vol[n-1,y-1])
{
tt=q_out*(Math.Pow(((tot_ht-elev[n-1,y-1])/root),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[n-1,y-1]+=tt;
up_in[n-1,y-1]+=tt;
for(i=n;ielev[x,y-1]&&water_depth[x,y-1]!=-9999)
{
tt=q_out*(Math.Pow(((tot_ht-elev[x,y-1])/DX),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[x,y-1]+=tt;
up_in[x,y-1]+=tt;
//up_out[x,y-1]+=tt;
temp_a+=tt;
max_flow[x,y,1]+=tt;
}
}
n=x;
while((n-x)elev[n+1,y-1]&&(n+1)lat_vol[n+1,y-1])
{
tt=q_out*(Math.Pow(((tot_ht-elev[n+1,y-1])/root),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[n+1,y-1]+=tt;
up_in[n+1,y-1]+=tt;
for(i=n;i>x;i--)
{
up_in[i,y-1]+=tt;
left_out[i, y - 1] += tt;
}
temp_a+=tt;
if(n==x)max_flow[x,y,2]+=tt;
}
n++;
}
discharge[x,y]=discharge[x,y]-temp_a;
up_out[x,y]+=temp_a;
}
/* add subsurface flow back in **/
discharge[x,y]+=threshold;
}
/* then route subsurface flow...*/
if(discharge[x,y]>0&&water_depth[x-1,y-1]!=-9999&&water_depth[x,y-1]!=-9999&&water_depth[x+1,y-1]!=-9999)
{
if(elev[x-1,y-1]<=ht||elev[x,y-1]<=ht||elev[x+1,y-1]<=ht)
{
tot_q=0;
temp_a=0;
q_out=discharge[x,y];
if(q_out>MIN_Q)q_out=MIN_Q;
if(elev[x-1,y-1]0)
{
x=down_scan[y,inc];
inc++;
ht=elev[x,y];
/* route water if not enough to flow */
if(water_depth[x,y-1]==-9999&&water_depth[x,y]!=-99)
{
discharge[x,y]=(area[x,y]*j_mean)*Math.Pow(DX,2);
water_depth[x,y]=-99;
}
else
{
discharge[x,y]+=((j_mean*Math.Pow(DX,2))/8); // 4 to 8 19/01/05
}
if(discharge[x,y]>0.01)
{
slope=max_bed_slope(x,y);
if(slope<0.002)slope=0.002;
threshold=K*slope*DX;
if(thresholdwater_depth[x,y])
{
water_depth[x,y]=depth;
lat_vol[x,y]=discharge[x,y];
}
}
/* then do surface routing */
if(x>1&&x<(xmax)&&discharge[x,y]>threshold&&water_depth[x-1,y+1]!=-9999&&water_depth[x,y+1]!=-9999&&water_depth[x+1,y+1]!=-9999)
{
tot_q=0;
temp_a=0;
/********* first sort out wet height *****/
discharge[x,y]-=threshold;
/***** now to route discharge d/s ***************/
tot_ht=elev[x,y]+depth;
//
// start of main routing bit
//
if(elev[x,y+1]elev[x,y]&&
elev[x,y+1]>elev[x,y]&&
elev[x+1,y+1]>elev[x,y])
{
if(elev[x-1,y+1]discharge[x,y])q_out=0; // line to prevent very very small depths increasing q_out disproportionaltely
if(lowest>tot_ht)q_out=0;
}
n=x;
while((x-n)elev[n-1,y+1]&&(n-1)>0&&water_depth[n-1,y+1]!=-9999)//&&q_out>lat_vol[n-1,y+1])
{
tot_q+=Math.Pow(((tot_ht-elev[n-1,y+1])/root),fexp);
n--;
}
if(tot_ht>elev[x,y+1]&&water_depth[x,y+1]!=-9999)
{
tot_q+=Math.Pow(((tot_ht-elev[x,y+1])/DX),fexp);
}
n=x;
while((n-x)elev[n+1,y+1]&&(n+1)lat_vol[n+1,y+1])
{
tot_q+=Math.Pow(((tot_ht-elev[n+1,y+1])/root),fexp);
n++;
}
n=x;
double tt=0; //temp variable
while((x-n)elev[n-1,y+1]&&(n-1)>0&&water_depth[n-1,y+1]!=-9999)//&&q_out>lat_vol[n-1,y+1])
{
tt=q_out*(Math.Pow(((tot_ht-elev[n-1,y+1])/root),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[n-1,y+1]+=tt;
down_in[n-1,y+1]+=tt;
for(i=n;ielev[x,y+1]&&water_depth[x,y+1]!=-9999)
{
tt=q_out*(Math.Pow(((tot_ht-elev[x,y+1])/DX),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[x,y+1]+=tt;
down_in[x,y+1]+=tt;
//down_out[x,y+1]+=tt;
temp_a+=tt;
max_flow[x,y,5]+=tt;
}
}
n=x;
while((n-x)elev[n+1,y+1]&&(n+1)lat_vol[n+1,y+1])
{
tt=q_out*(Math.Pow(((tot_ht-elev[n+1,y+1])/root),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[n+1,y+1]+=tt;
down_in[n+1,y+1]+=tt;
for(i=n;i>x;i--)
{
down_in[i,y+1]+=tt;
left_out[i, y + 1] += tt;
}
temp_a+=tt;
if(n==x)max_flow[x,y,4]+=tt;
}
n++;
}
discharge[x,y]=discharge[x,y]-temp_a;
down_out[x,y]+=temp_a;
}
discharge[x,y]+=threshold;
}
if(discharge[x,y]>0&&water_depth[x-1,y+1]!=-9999&&water_depth[x,y+1]!=-9999&&water_depth[x+1,y+1]!=-9999)
{
if(elev[x-1,y+1]<=ht||elev[x,y+1]<=ht||elev[x+1,y+1]<=ht)
{
tot_q=0;
temp_a=0;
q_out=discharge[x,y];
if(q_out>MIN_Q)q_out=MIN_Q;
if(elev[x-1,y+1]0)
{
y=cross_scan[x,inc];
inc++;
ht=elev[x,y];
if(water_depth[x-1,y]==-9999&&water_depth[x,y]!=-99)
{
discharge[x,y]=(area[x,y]*j_mean)*Math.Pow(DX,2);
water_depth[x,y]=-99;
}
else
{
discharge[x,y]+=((j_mean*Math.Pow(DX,2))/8); // 4 to 8 19/01/05
}
if(discharge[x,y]>0.01)
{
slope=max_bed_slope(x,y);
if(slope<0.002)slope=0.002;
threshold=K*slope*DX;
if(thresholdwater_depth[x,y])
{
water_depth[x,y]=depth;
lat_vol[x,y]=discharge[x,y];
}
}
//double totalal=0; int x1,y1;for(x1=1;x1<=xmax;x1++){for(y1=1;y1<=ymax;y1++){totalal+=discharge[x,y];}}if(totalal>100)Console.WriteLine("now9");
/* route water if not enough to flow */
/* then do surface routing */
if(y>1&&y<(ymax)&&discharge[x,y]>threshold&&water_depth[x+1,y-1]!=-9999&&water_depth[x+1,y]!=-9999&&water_depth[x+1,y+1]!=-9999)
{
tot_q=0;
temp_a=0;
discharge[x,y]-=threshold;
/***** now to route discharge d/s ***************/
tot_ht=elev[x,y]+depth;
//
// start of main routing bit
//
if(elev[x+1,y-1]elev[x,y]&&
elev[x+1,y]>elev[x,y]&&
elev[x+1,y+1]>elev[x,y])
{
if(elev[x+1,y-1]discharge[x,y])q_out=0; // line to prevent very very small depths increasing q_out disproportionaltely
if(lowest>tot_ht)q_out=0;
}
//max_flow[x,y,0]+=q_out;
n=y;
while((y-n)elev[x+1,n-1]&&(n-1)>0&&water_depth[x+1,n-1]!=-9999)//&&q_out>lat_vol[x+1,n-1])
{
tot_q+=Math.Pow(((tot_ht-elev[x+1,n-1])/root),fexp);
n--;
}
if(tot_ht>elev[x+1,y]&&water_depth[x+1,y]!=-9999)
{
tot_q+=Math.Pow(((tot_ht-elev[x+1,y])/DX),fexp);
}
n=y;
while((n-y)elev[x+1,n+1]&&(n+1)lat_vol[x+1,n+1])
{
tot_q+=Math.Pow(((tot_ht-elev[x+1,n+1])/root),fexp);
n++;
}
n=y;
double tt=0; // temp variable
while((y-n)elev[x+1,n-1]&&(n-1)>0&&water_depth[x+1,n-1]!=-9999)//&&q_out>lat_vol[x+1,n-1])
{
tt=q_out*(Math.Pow(((tot_ht-elev[x+1,n-1])/root),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[x+1,n-1]+=tt;
left_in[x+1,n-1]+=tt;
for(i=n;ielev[x+1,y]&&water_depth[x+1,y]!=-9999)
{
tt=q_out*(Math.Pow(((tot_ht-elev[x+1,y])/DX),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[x+1,y]+=tt;
left_in[x+1,y]+=tt;
//left_out[x+1,y]+=tt;
temp_a+=tt;
max_flow[x,y,3]+=tt;
}
}
n=y;
while((n-y)elev[x+1,n+1]&&(n+1)lat_vol[x+1,n+1])
{
tt=q_out*(Math.Pow(((tot_ht-elev[x+1,n+1])/root),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[x+1,n+1]+=tt;
left_in[x+1,n+1]+=tt;
for(i=n;i>y;i--)
{
left_in[x+1,i]+=tt;
down_out[x + 1, i] += tt;
}
temp_a+=tt;
if(n==y)max_flow[x,y,4]+=tt;
}
n++;
}
if(x==xmax)totty+=temp_a;
discharge[x,y]=discharge[x,y]-temp_a;
left_out[x,y]+=temp_a;
}
discharge[x,y]+=threshold;
}
if(discharge[x,y]>0&&water_depth[x+1,y-1]!=-9999&&water_depth[x+1,y]!=-9999&&water_depth[x+1,y+1]!=-9999)
{
if(elev[x+1,y-1]<=ht||elev[x+1,y]<=ht||elev[x+1,y+1]<=ht)
{
tot_q=0;
temp_a=0;
q_out=discharge[x,y];
if(q_out>MIN_Q)q_out=MIN_Q;
if(elev[x+1,y-1]=1;x--)
{
inc=1;
//drawwater(mygraphics);
while(cross_scan[x,inc]>0)
{
y=cross_scan[x,inc];
inc++;
ht=elev[x,y];
if(water_depth[x+1,y]==-9999&&water_depth[x,y]!=-99)
{
discharge[x,y]=(area[x,y]*j_mean)*Math.Pow(DX,2);
water_depth[x,y]=-99;
}
else
{
discharge[x,y]+=((j_mean*Math.Pow(DX,2))/8); // 4 to 8 19/01/05
}
if(discharge[x,y]>0.01)
{
slope=max_bed_slope(x,y);
if(slope<0.002)slope=0.002;
threshold=K*slope*DX;
if(thresholdwater_depth[x,y])
{
water_depth[x,y]=depth;
lat_vol[x,y]=discharge[x,y];
}
}
/* route water if not enough to flow */
/* then do surface routing */
if(y>1&&y<(ymax)&&discharge[x,y]>threshold&&water_depth[x-1,y-1]!=-9999&&water_depth[x-1,y]!=-9999&&water_depth[x-1,y+1]!=-9999)
{
tot_q=0;
temp_a=0;
/********* first sort out wet height *****/
/* starting with d/s slopes ****/
/***** now to route discharge d/s ***************/
discharge[x,y]-=threshold;
tot_ht=elev[x,y]+depth;
//
// start of main routing bit
//
if(elev[x-1,y-1]elev[x,y]&&
elev[x-1,y]>elev[x,y]&&
elev[x-1,y+1]>elev[x,y])
{
if(elev[x-1,y-1]discharge[x,y])q_out=0; // line to prevent very very small depths increasing q_out disproportionaltely
if(lowest>tot_ht)q_out=0;
}
n=y;
while((y-n)elev[x-1,n-1]&&(n-1)>0&&water_depth[x-1,n-1]!=-9999)//&&q_out>lat_vol[x-1,n-1])
{
tot_q+=Math.Pow(((tot_ht-elev[x-1,n-1])/root),fexp);
n--;
}
if(tot_ht>elev[x-1,y]&&water_depth[x-1,y]!=-9999)
{
tot_q+=Math.Pow(((tot_ht-elev[x-1,y])/DX),fexp);
}
n=y;
while((n-y)elev[x-1,n+1]&&(n+1)lat_vol[x-1,n+1])
{
tot_q+=Math.Pow(((tot_ht-elev[x-1,n+1])/root),fexp);
n++;
}
n=y;
double tt=0; // temp variable
while((y-n)elev[x-1,n-1]&&(n-1)>0&&water_depth[x-1,n-1]!=-9999)//&&q_out>lat_vol[x-1,n-1])
{
tt=q_out*(Math.Pow(((tot_ht-elev[x-1,n-1])/root),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[x-1,n-1]+=tt;
right_in[x-1,n-1]+=tt;
for(i=n;ielev[x-1,y]&&water_depth[x-1,y]!=-9999)
{
tt=q_out*(Math.Pow(((tot_ht-elev[x-1,y])/DX),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[x-1,y]+=tt;
right_in[x-1,y]+=tt;
//right_out[x-1,y]+=tt;
temp_a+=tt;
max_flow[x,y,7]+=tt;
}
}
n=y;
while((n-y)elev[x-1,n+1]&&(n+1)lat_vol[x-1,n+1])
{
tt=q_out*(Math.Pow(((tot_ht-elev[x-1,n+1])/root),fexp)/tot_q);
if(tt>double.Parse(Q2box.Text))
{
discharge[x-1,n+1]+=tt;
right_in[x-1,n+1]+=tt;
for(i=n;i>y;i--)
{
right_in[x-1,i]+=tt;
down_out[x - 1, i] += tt;
}
temp_a+=tt;
if(n==y)max_flow[x,y,6]+=tt;
}
n++;
}
discharge[x,y]=discharge[x,y]-temp_a;
right_out[x,y]+=temp_a;
}
discharge[x,y]+=threshold;
}
if(discharge[x,y]>0&&water_depth[x-1,y-1]!=-9999&&water_depth[x-1,y]!=-9999&&water_depth[x-1,y+1]!=-9999)
{
if(elev[x-1,y-1]<=ht||elev[x-1,y]<=ht||elev[x-1,y+1]<=ht)
{
tot_q=0;
temp_a=0;
q_out=discharge[x,y];
if(q_out>MIN_Q)q_out=MIN_Q;
if(elev[x-1,y-1]=1;y--)
{
inc=1;
while(down_scan[y,inc]>0)
{
x=down_scan[y,inc];
inc++;
/** calculate max flow out direction **/
tot=0;
for(n=1;n<=8;n++)
{
if(max_flow[x,y,n]>tot)
{
valz=n;
tot=max_flow[x,y,n];
//max_flow[x,y,0]=tot; /* stores max discharge out in 0 of max_flow array. - now carried out in route routines*/
}
}
if(tot>0)flow_dir[x,y,1]=valz;
/** calculate flow in direction **/
tot=0;
if(max_flow[x,y-1,5]>tot)
{
valz=1;
tot=max_flow[x,y-1,5];
}
if(max_flow[x+1,y-1,6]>tot)
{
valz=2;
tot=max_flow[x+1,y-1,6];
}
if(max_flow[x+1,y,7]>tot)
{
valz=3;
tot=max_flow[x+1,y,7];
}
if(max_flow[x+1,y+1,8]>tot)
{
valz=4;
tot=max_flow[x+1,y+1,8];
}
if(max_flow[x,y+1,1]>tot)
{
valz=5;
tot=max_flow[x,y+1,1];
}
if(max_flow[x-1,y+1,2]>tot)
{
valz=6;
tot=max_flow[x-1,y+1,2];
}
if(max_flow[x-1,y,3]>tot)
{
valz=7;
tot=max_flow[x-1,y,3];
}
if(max_flow[x-1,y-1,4]>tot)
{
valz=8;
tot=max_flow[x-1,y-1,4];
}
if(tot>0)flow_dir[x,y,0]=valz;
// calc balance of flow out vs in,
double tot2=0;
double tot3 = 0;
int totinc=0;
int tot2c = 0;
// if(max_flow[x,y,1]>max_flow[x,y-1,5])tot2+=max_flow[x,y,1]-max_flow[x,y-1,5];
// if(max_flow[x,y,2]>max_flow[x+1,y-1,6])tot2+=max_flow[x,y,2]-max_flow[x+1,y-1,6];
// if(max_flow[x,y,3]>max_flow[x+1,y,7])tot2+=max_flow[x,y,3]-max_flow[x+1,y,7];
// if(max_flow[x,y,4]>max_flow[x+1,y+1,8])tot2+=max_flow[x,y,4]-max_flow[x+1,y+1,8];
// if(max_flow[x,y,5]>max_flow[x,y+1,1])tot2+=max_flow[x,y,5]-max_flow[x,y+1,1];
// if(max_flow[x,y,6]>max_flow[x-1,y+1,2])tot2+=max_flow[x,y,6]-max_flow[x-1,y+1,2];
// if(max_flow[x,y,7]>max_flow[x-1,y,3])tot2+=max_flow[x,y,7]-max_flow[x-1,y,3];
// if(max_flow[x,y,8]>max_flow[x-1,y-1,4])tot2+=max_flow[x,y,8]-max_flow[x-1,y-1,4];
//if (up_in[x, y] > down_in[x, y - 1]) tot2 += up_in[x, y] - down_in[x, y - 1];
//if (down_in[x, y] > up_in[x, y + 1]) tot2 += down_in[x, y] - up_in[x, y + 1];
//if (left_in[x, y] > right_in[x + 1, y]) tot2 += left_in[x, y] - right_in[x + 1, y];
//if (right_in[x, y] > left_in[x - 1, y]) tot2 += right_in[x, y] - left_in[x - 1, y];
if (up_out[x, y] - down_in[x, y] > tot2) tot2 = up_out[x, y] - down_in[x, y];
if (down_out[x, y] - up_in[x, y] > tot2) tot2 = down_out[x, y] - up_in[x, y];
if (left_out[x, y] - right_in[x, y] > tot2) tot2 = left_out[x, y] - right_in[x, y];
if (right_out[x, y] - left_in[x, y] > tot2) tot2 = right_out[x, y] - left_in[x, y];
// if(up_out[x,y]-down_out[x,y]>tot2)tot2=up_out[x,y]-down_out[x,y];
// if(down_out[x,y]-up_out[x,y]>tot2)tot2=down_out[x,y]-up_out[x,y];
//
// double tot3=0;
// if(left_out[x,y]-right_out[x,y]>tot3)tot3=left_out[x,y]-right_out[x,y];
// if(right_out[x,y]-left_out[x,y]>tot3)tot3=right_out[x,y]-left_out[x,y];
//
// if(up_out[x,y]-down_out[x,y]>tot2)tot2=up_out[x,y]-down_out[x,y];
// if(down_out[x,y]-up_out[x,y]>tot2)tot2=down_out[x,y]-up_out[x,y];
// if(left_out[x,y]-right_out[x,y]>tot2)tot2=left_out[x,y]-right_out[x,y];
// if(right_out[x,y]-left_out[x,y]>tot2)tot2=right_out[x,y]-left_out[x,y];
//if (up_out[x, y] > 0) tot2c++;
//if (down_out[x, y] > 0) tot2c++;
//if (left_out[x, y] > 0) tot2c++;
//if (right_out[x, y] > 0) tot2c++;
//if(tot2c>0)max_flow[x, y, 0] = tot2/tot2c;
max_flow[x, y, 0] = tot2/2;
// next section calculates Tau
// next line to make sure that if no water smoothing, then water_depth2 us updated with correct water depths
if (checkBox3.Checked == false)water_depth2[x,y]=water_depth[x,y];
if(water_depth[x,y]>water_depth_erosion_threshold)
{
// re- calcualate discharge (max_flow[x,y,0]) accounting for pool depths..
if(pool_depth[x,y]>water_depth[x,y])pool_depth[x,y]=water_depth[x,y];
if(qcounter[x,y]==0)qcounter[x,y]=1;
if(max_flow[x,y,0]<0)max_flow[x,y,0]=0;//Console.WriteLine(Convert.ToString(max_flow[x,y,0]));
double slope=0;
if(wslope_box.Checked==true)//&&mean_bed_slope(x,y)>0)
{
slope=mean_ws_slope(x,y);
if(slope==0)slope=mean_ws_slope2(x,y);
}
if(bedslope_box.Checked==true)slope=mean_bed_slope(x,y);
if(slope>0.01)slope=0.01; // to get rid of too steep slopes
Tau[x,y]=water_depth[x,y]*slope*1000*9.8;
if(veltaubox.Checked==true)
{
double vel=(max_flow[x,y,0]/(DX*water_depth[x,y])); // calculating velocity
double ci=9.81*Math.Pow(calc_manning(x,y),2)*Math.Pow(water_depth[x,y],-0.33);// calcualting drag coeffiecuent
//if (ci > 0.05) ci = 0.05;
if(vel>2)vel=2; // if vel too high cut it
Tau[x,y]=1000*ci*Math.Pow(vel,2);
}
}
else
{
Tau[x,y]=-9999;
}
}
}
}
private void zero_values()
{
int x,y,z,n;
double act=0.5;
for(y=0;y<=ymax;y++)
{
for(x=0;x<=xmax;x++)
{
area[x,y]=0;
elev[x,y]=0;
bedrock[x,y]=0;
init_elevs[x,y]=elev[x,y];
discharge[x,y]=0;
water_depth[x,y]=0;
index[x,y]=-9999;
veg[x,y,0]=0; // density
veg[x,y,1]=0; // elevation
veg[x,y,2]=0; // jw density
veg[x,y,3]=0; // height
lat_vol[x,y]=0;
edge[x,y]=0;
edge2[x,y]=0;
pool_depth[x,y]=0;
qcounter[x,y]=0;
lat_vol[x,y]=0;
for(n=0;n<=8;n++)max_flow[x,y,n]=0;
for(n=0;n<=1;n++)flow_dir[x,y,n]=0;
}
}
for(x=1;x<((xmax*ymax)/LIMIT);x++)
{
for(y=0;y<=G_MAX;y++)
{
for(n=0;n<=(TRACERS-1);n++)
{
grain[x,y,n]=0;
temp[x,y,n]=0;
extra_elev[x]=0;
}
}
for(z=0;z<=9;z++)
{
for(y=0;y<=G_MAX-2;y++)
{
for(n=0;n<=(TRACERS-1);n++)
{
strata[x,z,y,n]=0;
}
}
}
}
for(x=0;x<=1000;x++)
{
minesites[x,0]=0;
minesites[x,1]=0;
}
//
// for(x=0;x<=100000;x++)
// {
// hourly_rain_data[x]=0;
// }
// for(x=1;x<=xmax;x++)
// {
// for(y=1;y<=ymax;y++)
// {
// if(y<=100)
// {
// elev[x,y]=600-(x*1);
// elev[x,y]-=(y*1);
// }
// if(y>100)
// {
// elev[x,y]=600-(x*1);
// elev[x,y]-=((200-y)*1);
// }
// if(x>400)elev[x,y]=100;
// if(x>400&&y==1)elev[x,y]+=2;
// if(x>400&&y==ymax)elev[x,y]+=2;
//
// bedrock[x,y]=0.2;
// init_elevs[x,y]=elev[x,y];
// }
// }
}
void calc_soil_saturation() //
{
int x,y,n,inc;
double coeff,Qsum;
for (y=1; y<=ymax; y++)
{
inc = 1;
while (down_scan[y,inc] > 0)
{
x = down_scan[y,inc];
inc++;
soil_saturation[x,y] = area[x,y] * j_mean;
}
}
}
void calc_hillshade() //
{
//Local variables
int x, y;
double slopemax;
double slope;
int slopetot;
double local_Illumination;
// Initialize Hillshade Paramaters
double azimuth = 315 * (3.141592654/180); // Default of 315 degrees converted to radians
double altitude = 45 * (3.141592654/180); // Default of 45 degrees converted to radians
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
if(elev[x,y] != -9999 && elev[x,y] > 0)
{
slopemax=0.0;
slope=0.0;
slopetot=0;
// Do slope analysis and Aspect Calculation first
if(elev[x,y] > elev[x,y-1] && elev[x,y-1] != -9999) // North 0
{
slope = Math.Pow((elev[x,y]-elev[x,y-1])/root,1);
if(slope > slopemax)
{
slopemax=slope;
slopetot++;
aspect[x,y] = 0 * (3.141592654/180);
}
}
if(elev[x,y] > elev[x+1,y-1] && elev[x+1,y-1] != -9999) // Northeast 45
{
slope = Math.Pow((elev[x,y]-elev[x+1,y-1])/DX,1);
if(slope > slopemax)
{
slopemax=slope;
slopetot++;
aspect[x,y] = 45 * (3.141592654/180);
}
}
if(elev[x,y] > elev[x+1,y] && elev[x+1,y] != -9999) // East 90
{
slope = Math.Pow((elev[x,y]-elev[x+1,y])/root,1);
if(slope > slopemax)
{
slopemax=slope;
slopetot++;
aspect[x,y] = 90 * (3.141592654/180);
}
}
if(elev[x,y] > elev[x+1,y+1] && elev[x+1,y+1] != -9999) // SouthEast 135
{
slope = Math.Pow((elev[x,y]-elev[x+1,y+1])/root,1);
if(slope > slopemax)
{
slopemax=slope;
slopetot++;
aspect[x,y] = 135 * (3.141592654/180);
}
}
if(elev[x,y] > elev[x,y+1] && elev[x,y+1] != -9999) // South 180
{
slope = Math.Pow((elev[x,y]-elev[x,y+1])/DX,1);
if(slope > slopemax)
{
slopemax=slope;
slopetot++;
aspect[x,y] = 180 * (3.141592654/180);
}
}
if(elev[x,y] > elev[x-1,y+1] && elev[x-1,y+1] != -9999) // SouthWest 225
{
slope = Math.Pow((elev[x,y]-elev[x-1,y+1])/root,1);
if(slope > slopemax)
{
slopemax=slope;
slopetot++;
aspect[x,y] = 225 * (3.141592654/180);
}
}
if(elev[x,y] > elev[x-1,y] && elev[x-1,y] != -9999) // West 270
{
slope = Math.Pow((elev[x,y]-elev[x-1,y])/root,1);
if(slope > slopemax)
{
slopemax=slope;
slopetot++;
aspect[x,y] = 270;
}
}
if(elev[x,y] > elev[x-1,y-1] && elev[x-1,y-1] != -9999) // Northwest 315
{
slope = Math.Pow((elev[x,y]-elev[x-1,y-1])/DX,1);
if(slope > slopemax)
{
slopemax=slope;
slopetot++;
aspect[x,y] = 315 * (3.141592654/180);
}
}
if (slope > 0) slopeAnalysis[x,y] = slopemax;// Tom's: (slope/slopetot); ?
// Convert slope to radians
slopeAnalysis[x,y] = System.Math.Atan(slopeAnalysis[x,y]);
// Do Hillshade Calculation
local_Illumination = 255 * ((System.Math.Cos(azimuth)
* System.Math.Sin(slopeAnalysis[x,y])
* System.Math.Cos(aspect[x,y] - azimuth))
+ (System.Math.Sin(altitude)
* System.Math.Cos(slopeAnalysis[x,y])));
hillshade[x,y] = System.Math.Abs(local_Illumination);
}
}
}
} // End calc_hillshade()
void calc_flow_velocity() //
{
int x,y,n,inc;
double coeff,Qsum;
for (y=1; y<=ymax; y++)
{
inc = 1;
// Reminder, can use either down_scan or cross_scan to only loop
// through active cells. Otherwise, would have to loop through
// entire grid
while (down_scan[y,inc] > 0)
{
x = down_scan[y,inc];
inc++;
if (max_flow[x,y,0] > 0.0)
{
// take coeff out of inner loop to save on computation
coeff = 1.0 / (water_depth[x,y] * DX);
Qsum = 0.0;
for (n=0; n<=8; n++)
{
flow_velocity[x,y,n] = max_flow[x,y,n] * coeff;
if (n >= 1) Qsum += max_flow[x,y,n];
}
flow_velocity[x,y,9] = Qsum * coeff;
}
}
}
} // End calc_flow_velocity()
void Color_HSVtoRGB() //
{
// Convert HSV to RGB.
// Made this a seperate function as it is called multiple times in drawwater().
if (sat == 0)
{
// If sat is 0, all colors are the same.
// This is some flavor of gray.
red = val;
green = val;
blue = val;
}
else
{
double pFactor;
double qFactor;
double tFactor;
double fractionalSector;
int sectorNumber;
double sectorPos;
// The color wheel consists of six 60 degree sectors.
// Figure out which sector you are in.
sectorPos = hue / 60;
sectorNumber = (int)(Math.Floor(sectorPos));
// get the fractional part of the sector.
// That is, how many degrees into the sector are you?
fractionalSector = sectorPos - sectorNumber;
// Calculate values for the three axes
// of the color.
pFactor = val * (1 - sat);
qFactor = val * (1 - (sat * fractionalSector));
tFactor = val * (1 - (sat * (1 - fractionalSector)));
// Assign the fractional colors to r, g, and b based on the sector the angle is in.
switch (sectorNumber)
{
case 0:
red = val;
green = tFactor;
blue = pFactor;
break;
case 1:
red = qFactor;
green = val;
blue = pFactor;
break;
case 2:
red = pFactor;
green = val;
blue = tFactor;
break;
case 3:
red = pFactor;
green = qFactor;
blue = val;
break;
case 4:
red = tFactor;
green = pFactor;
blue = val;
break;
case 5:
red = val;
green = pFactor;
blue = qFactor;
break;
}
}
}
void drawwater(System.Drawing.Graphics graphics)//
{
int x, y, z, n, n1, tot;
int redcol = 0, greencol = 0, bluecol = 0, alphacol = 255;
int t=1, t_y=1;
double tot_max, ztemp, erotemp = 0, tomsedi = 0;
Pen waterpen, grainpen;
// Set Graphics Display Size
if (xmax <= 0) xmax = 1;
graphics.PageScale=(float) 0.5 * this.Width / xmax; //
t = (int) (this.Width/xmax);
if (t < 1) t = 1;
// These loop through the entire grid
// DEM
if (menuItem30.Checked == true)
{
double zDEM;
double zCalc, zMin = 100000.0, zMax = 0.0, zRange, hsMin = 0, hsMax = 255, hsRange, hs;
double valMin = 0.0;
double valMax = 1.0;
calc_hillshade(); // Call up routine
// First, find max, min and range of DEM and Hillshade
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
zCalc = elev[x,y];
if(zCalc != -9999)
{
if (zCalc < zMin) zMin = zCalc;
if (zCalc > zMax) zMax = zCalc;
hs = hillshade[x,y];
if (hs < hsMin) hsMin = hs;
if (hs > hsMax) hsMax = hs;
}
}
}
zRange = zMax - zMin;
hsRange = hsMax - hsMin;
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
if (elev[x,y] > 0.0)
{
// HILLSHADE: Draw first underneath
// set gray scale intensity
hue = 360.0; // hue doesn't matter for gray shade
sat = 0.0; // ensures gray shade
valMin = 0.0;
valMax = 1.0;
val = ((hillshade[x,y]/255) * (valMax - valMin)) + valMin; // uses maximum contrast
// val = (((hillshade[x,y] - hsMin)/(zRange)) * (valMax - valMin)) + valMin; // lower contrast
Color_HSVtoRGB(); // Call up color conversion
redcol = System.Convert.ToInt32(red*255);
greencol = System.Convert.ToInt32(green*255);
bluecol = System.Convert.ToInt32(blue*255);
alphacol = 255;
SolidBrush brush2 = new SolidBrush(Color.FromArgb(alphacol,redcol,greencol,bluecol));
graphics.FillRectangle(brush2,x*t,y*t,t,t);
// DEM
zDEM = (elev[x,y]);
// Sets hue based on desired color range (in decimal degrees; max 360)
double hueMin = 30.0;
double hueMax = 85.0;
// hue = (((zDEM - zMin)/(zRange)) * (hueMax - hueMin)) + hueMin; // Forward
hue = hueMax -(((zDEM - zMin)/(zRange)) * (hueMax - hueMin)); // Reverse
// Set saturation based on desired range
double satMin = 0.50;
double satMax = 0.95;
sat = (((zDEM - zMin)/(zRange)) * (satMax - satMin)) + satMin;
// sat = 0; // Use for grey-scale DEM only!
// Set value based on desired range
valMin = 0.40;
valMax = 0.80;
val = (((zDEM - zMin)/(zRange)) * (valMax - valMin)) + valMin;
// val = valMax - (((zDEM - zMin)/(zRange)) * (valMax - valMin));
Color_HSVtoRGB(); // Call up color conversion
redcol = System.Convert.ToInt32(red*255);
greencol = System.Convert.ToInt32(green*255);
bluecol = System.Convert.ToInt32(blue*255);
alphacol = 125;
SolidBrush brush = new SolidBrush(Color.FromArgb(alphacol,redcol,greencol,bluecol));
graphics.FillRectangle(brush,x*t,y*t,t,t);
} // Close of Entire Grid Mask
} // Close of Column Loop
} // Close of Row Loop
} // Close of DEM check box (menuitem34)
// Find Ranges for those in Active Area
// Water Depth Range:
double wdCalc, wdMin = 100000.0, wdMax =-10.0, wdRange;
// Find Water Depth Ranges
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
wdCalc = Tau[x,y];
if(wdCalc>0)
{
if(wdCalcwdMax)wdMax=wdCalc;
}
}
}
wdRange = wdMax - wdMin;
// All these loop through just the 'Active Area'
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
if (1>0) // Index masks out so only 'active cells' shown was if(index[x,y]>-9999)
{
// Water Depth
if(menuItem3.Checked==true&&water_depth[x,y]>water_depth_erosion_threshold)//MIN_Q)//||discharge[x,y]>0)
{
z=0;
z=(int)(water_depth[x,y]*125);
//z=(int)((width[x,y]/(1/edge2[x,y]))*256);
//z=(int)((2/(((2.131*Math.Pow(edge2[x,y],-1.0794))*DX)/(DX*width[x,y])))*1250);
//z=(int)(edge2[x,y]*1000);
//z=(int)((max_flow[x,y,0]/DX)*1);
//if(max_flow[x,y,0]<(0.5))z=255;
//z=(int)(max_flow[x,y,3]*10);
//z = 0; z = (int)(Math.Pow(edge2[x, y], 0.7) * 2 * 256);
if(z<0)z=0;
if(z>254)z=254;
greencol=255-z;
redcol=z;
bluecol = 255;
alphacol = 255;
SolidBrush brush = new SolidBrush(Color.FromArgb(alphacol,redcol,greencol,bluecol));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
// DoD Erosion/ Depostion
if(menuItem4.Checked==true)
{
tomsedi+=(init_elevs[x,y]-elev[x,y]);
tomsedi-=(Vsusptot[x,y])/(DX*DX);
if(init_elevs[x,y]-elev[x,y]>0.001) //eroding
{
z=(int)((init_elevs[x,y]-elev[x,y])*256);
if(z<0)z=0;
if(z>254)z=254;
greencol=255-z;
redcol=z;
// red green blue
SolidBrush brush = new SolidBrush(Color.FromArgb(255,greencol,greencol));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
if(init_elevs[x,y]-elev[x,y]<-0.001) //depositing
{
z=(int)((elev[x,y]-init_elevs[x,y])*256);
if(z<0)z=0;
if(z>254)z=254;
greencol=z;
redcol=255-z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,255,redcol));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
// if(init_elevs[x,y]-elev[x,y]>0.0001&&init_elevs[x,y]-elev[x,y]<0.1)graphics.DrawRectangle(Pens.Yellow,x*t,y*t,t,t);
// if(init_elevs[x,y]-elev[x,y]>0.1&&init_elevs[x,y]-elev[x,y]<0.2)graphics.DrawRectangle(Pens.Orange,x*t,y*t,t,t);
// if(init_elevs[x,y]-elev[x,y]>0.2&&init_elevs[x,y]-elev[x,y]<10)graphics.DrawRectangle(Pens.Red,x*t,y*t,t,t);
// if(init_elevs[x,y]-elev[x,y]<-0.0001&&init_elevs[x,y]-elev[x,y]>-0.1)graphics.DrawRectangle(Pens.LightGreen,x*t,y*t,t,t);
// if(init_elevs[x,y]-elev[x,y]<-0.1&&init_elevs[x,y]-elev[x,y]>-0.2)graphics.DrawRectangle(Pens.Green,x*t,y*t,t,t);
// if(init_elevs[x,y]-elev[x,y]<-0.2&&init_elevs[x,y]-elev[x,y]>-10)graphics.DrawRectangle(Pens.DarkGreen,x*t,y*t,t,t);
}
if(menuItem5.Checked==true)
{
if(1>0)//if(index[x,y]!=-9999)
{
z=(int)(veg[x,y,1]*256);
z = (int)(edge2[x, y] * 256);
//z=qcounter[x,y]*5;
//z=(int)((lat_vol[x,y]-discharge[x,y])*25);
//z=(int)(max_flow[x,y,0]*12.5); // discharge
//z=(int)((right_out[x,y]+left_out[x,y]+up_out[x,y]+down_out[x,y])*12.5);
//z=(int) ((pool_depth[x,y])*256); // pool depth
//z=(int)(20*width[x,y]); // width
//z=(int)((width[x,y]/(1/edge2[x,y]))*256);
//z=(int)((max_flow[x,y,0]/(DX*water_depth[x,y]))/Math.Pow(9.8*water_depth[x,y],0.5)*125);
//z = 0;
//z = (int)(Math.Pow(edge2[x, y], 0.7) * 256);
if (z < 0) z = 0;
if (z > 254) z = 254;
greencol = z;
redcol = 255 - z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol, 255, redcol));
graphics.FillRectangle(brush, x * t, y * t, t, t);
// double tot2 = 0;
// int tot3 = 99;
// double xplus = (left_out[x, y] - right_in[x, y]);
// double xminus = (right_out[x, y] - left_in[x, y]);
// double yplus = (up_out[x, y] - down_in[x, y]);
// double yminus = (down_out[x, y] - up_in[x, y]);
// double xcomp = xplus - xminus;
// double ycomp = yplus - yminus;
// if (yplus > 0 && yplus > tot2) { tot2 = yplus; tot3 = 0; }
// if (yplus > 0 && xplus > 0 && (xplus + yplus) / 1.44 > tot2) { tot2 = (xplus + yplus) / 1.44; tot3 = 1; }
// //if ((ycomp + xcomp)/2 > tot2) { tot2 = (ycomp + xcomp)/2; tot3 = 1; }
// if (xplus>0 && xplus > tot2) { tot2 = xplus; tot3 = 2; }
// //if ((xcomp + (1 - ycomp))/2 > tot2) { tot2 = (xcomp + (1 - ycomp))/2; tot3 = 3; }
// if (yminus>0&&yminus > tot2) { tot2 = yminus; tot3 = 4; }
//// if (((1 - xcomp) + (1 - ycomp))/2 > tot2) { tot2 = ((1 - xcomp) + (1 - ycomp))/2; tot3 = 5; }
// if (xminus>0&&xminus > tot2) { tot2 = xminus; tot3 = 6; }
//// if (((1 - xcomp) + ycomp)/2> tot2) { tot2 = ((1 - xcomp) + ycomp)/2; tot3 = 7; }
// if (tot3 == 0) graphics.DrawRectangle(Pens.Green, x * t, y * t, t, t);
// if (tot3 == 1) graphics.DrawRectangle(Pens.DarkBlue, x * t, y * t, t, t);
// if (tot3 == 2) graphics.DrawRectangle(Pens.Blue, x * t, y * t, t, t);
// if (tot3 == 3) graphics.DrawRectangle(Pens.LightBlue, x * t, y * t, t, t);
// if (tot3 == 4) graphics.DrawRectangle(Pens.White, x * t, y * t, t, t);
// if (tot3 == 5) graphics.DrawRectangle(Pens.Red, x * t, y * t, t, t);
// if (tot3 == 6) graphics.DrawRectangle(Pens.Orange, x * t, y * t, t, t);
// if (tot3 == 7) graphics.DrawRectangle(Pens.Yellow, x * t, y * t, t, t);
// if (tot3 == 8) graphics.DrawRectangle(Pens.Black, x * t, y * t, t, t);
// if (tot3 == 9) graphics.DrawRectangle(Pens.DarkViolet, x * t, y * t, t, t);
// if (tot3 == 10) graphics.DrawRectangle(Pens.Red, x * t, y * t, t, t);
}
}
// Tracer Concentration
if(menuItem6.Checked==true)//&&TRACERS>1)
{
if(1>0)
{
double temptot=0;
int dir;
// for (dir=1;dir<=8;dir++)
// {
// int x2,y2;
// x2 = x + deltaX[dir];
// y2 = y + deltaY[dir];
// double temp1=0;
// double temp2=max_flow[x,y,0];
// double temp3 =0;
// if(edge[x2,y2]>-9999)
// {
// if(index[x2,y2]!=-9999)for(n=1;n<=G_MAX;n++)temp3+=temp_tot(index[x2,y2],n);
// if(temp3>0)temp3=0;
// temp3=0-temp3;
// if(edge[x,y]>0&&edge[x2,y2]water_depth_erosion_threshold)
// {
// if(((2.131*Math.Pow(edge[x,y],-1.0794))*DX)/(25)>2&&((2.131*Math.Pow(edge[x,y],-1.0794))*DX)/(25)<50)
// {
// temp1=(2/(((2.131*Math.Pow(edge[x,y],-1.0794))*DX)/(25)))*0.000002;//*temp3;//*(max_flow[x2,y2,0]/(water_depth[x2,y2]*DX));
// }
//// else if(((2.131*Math.Pow(edge[x,y],-1.0794))*DX)/(water_depth[x2,y2]*50)>1)
//// {
//// temp1=(0.5*(((2.131*Math.Pow(edge[x,y],-1.0794))*DX)/(50)))*0.005*temp3;//*(max_flow[x2,y2,0]/(water_depth[x2,y2]*DX));
//// }
// }
// temptot+=temp1;
// }
// }
//output lateral amount..
z=(int)(temptot*30000000);
z=(int)((lat_vol[x,y]-discharge[x,y])*25);
z=(int)((pool_depth[x,y])*256);
z=(int) (calc_manning(x,y)*3000);
//Console.WriteLine(Convert.ToString(temptot*10000));
if(z<0)z=0;
if(z>254)z=254;
greencol=255-z;
redcol=z;
SolidBrush brush = new SolidBrush(Color.FromArgb(255,greencol,redcol));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
// now to draw second teir
if(menuItem7.Checked==true&&edge[x,y]>-9999)
{
if(edge[x,y]>=0) //inside
{
z=0;
z=(int)((edge[x,y])*1000);
if(z<0)z=0;
// z=(int)((2.131*Math.Pow(edge[x,y],-1.0794))*DX);
// z=254-z;
if(z>254)z=254;
if(z<0)z=0;
greencol=255-z;
redcol=z;
// red green blue
SolidBrush brush = new SolidBrush(Color.FromArgb(255,greencol,greencol));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
if(edge[x,y]<0) //outside
{
z=(int)((0-edge[x,y])*1000);
if(z<0)z=0;
if(z>254)z=254;
// z=(int)((2.131*Math.Pow(edge[x,y],-1.0794))*DX);
// z=254+z;
// if(z>254)z=254;
// if(z<0)z=0;
greencol=z;
redcol=255-z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,255,redcol));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
if(menuItem8.Checked==true)
{
if(Tau[x,y]>0)
{
z=(int)(Tau[x,y]*(255/wdRange));
//Console.WriteLine(Convert.ToString(Tau[x,y]));
if(z<0)z=0;
if(z>254)z=254;
//if(z>100)z=254;
greencol=255-z;
redcol=z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
// D50
if(menuItem9.Checked==true)
{
if(index[x,y]!=-9999)
{
tot_max=d50(index[x,y])*2000;
//Console.WriteLine((Convert.ToString(tot_max)));
tot=(int)tot_max;
if(tot>255)tot=255;
if(tot<0)tot=0;
// if(grain[index[x,y],0,0]>0.19)
// {
// tot=0;
// }
SolidBrush brush = new SolidBrush(Color.FromArgb(255-(tot*1),255-(tot*1),255-(tot*1)));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
// Tracer
if(menuItem10.Checked==true&&TRACERS>1)
{
if(index[x,y]!=-9999&&grain[index[x,y],1,1]>0)
{
ztemp=0;
for(n=1;n254)z=254;
greencol=255-z;
redcol=z;
SolidBrush brush = new SolidBrush(Color.FromArgb(255,greencol,redcol));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
// Pits
if(menuItem26.Checked==true)
{
if(1==1)
{
z=(int)area[x,y];
if(z<0)z=0;
if(z>254)z=254;
greencol=255-z;
redcol=z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
graphics.FillRectangle(brush,x*t,y*t,t,t);
// //elev[x,y]=elev[x,y]-0.005; // removed MJ 23/03/05, to be consistent with slope calc in erode()
// if (water_depth[x,y] > 0.0&&elev[x,y]<=elev[x,y-1]&&elev[x,y]<=elev[x+1,y-1]&&elev[x,y]<=elev[x+1,y]&&elev[x,y]<=elev[x+1,y+1]&&elev[x,y]<=elev[x,y+1]&&elev[x,y]<=elev[x-1,y+1]&&elev[x,y]<=elev[x-1,y]&&elev[x,y]<=elev[x-1,y-1])
// {
// z=(250);
//
// if(z<0)z=0;
// if(z>254)z=254;
//
// greencol=255-z;
// redcol=z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
// //elev[x,y]=elev[x,y]+0.005; // removed MJ 23/03/05, to be consistent with slope calc in erode()
}
}
// Suspended Sediment Concentration
if(menuItem27.Checked==true)
{
if(index[x,y]!=-9999)
{
if (Csusptot[x,y] > 0.0)
{
z=(int)(Csusptot[x,y]*25600);
if(z<0)z=0;
if(z>254)z=254;
greencol=255-z;
redcol=z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
}
// Suspended Sediment Volume
if(menuItem28.Checked==true)
{
if(index[x,y]!=-9999)
{
if (Vsusptot[x,y] > 0.0)
{
z=(int)(Vsusptot[x,y]*50);
if(z<0)z=0;
if(z>254)z=254;
greencol=255-z;
redcol=z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
}
// Flow Velocity
if (menuItem31.Checked == true) //
{
if (index[x,y] != -9999)
{
if (max_flow[x,y,0] > 0.0)
{
z=0;
z=(int)((max_flow[x,y,0]/(DX*water_depth[x,y]))*100);
//if(yyy>0.25)z=254;
if (z < 0) z = 0;
if (z > 254) z = 254;
greencol = 255-z;
redcol = z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
}
// Soil Saturation
if (menuItem32.Checked == true) //
{
if (index[x,y] != -9999)
{
if (soil_saturation[x,y] > 0.0)
{
z = (int)(soil_saturation[x,y] * 10);
if (z < 0) z = 0;
if (z > 254) z = 254;
greencol = 255-z;
redcol = z;
SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
graphics.FillRectangle(brush,x*t,y*t,t,t);
}
}
}
} // Close of nodata check for 'active' grid only
} // Close of Collumn Loop
} // Close of Row Loop
this.QsStatusPanel.Text=string.Format("Qs = {0:F8}",tomsedi*DX*DX);
} // Close of drawwater() //
// void drawwater(System.Drawing.Graphics graphics)//
// {
// int x, y, z, n, n1, tot;
// int redcol = 0, greencol = 0, bluecol = 0, alphacol = 255;
// int t=1, t_y=1;
// double tot_max, ztemp, erotemp = 0, tomsedi = 0;
// Pen waterpen, grainpen;
//
// if(xmax<=0)xmax=1;
// //graphics.PageScale=this.Width/xmax;
// graphics.PageScale=(float) 0.5*this.Width/xmax; //
//
// //MessageBox.Show(Convert.ToString(this.Width), "Simulation", MessageBoxButtons.OK);
// // hard code scaling..
// t=(int)(this.Width/xmax);
// if(t<1)t=1;
//
// for(x=1;x<=xmax;x++)
// {
// for(y=1;y<=ymax;y++)
// {
// // if(water_depth[x,y]>0.03&&water_depth[x,y]<0.1)graphics.DrawRectangle(Pens.LightBlue,x,y,t,t);
// // if(water_depth[x,y]>=0.1&&water_depth[x,y]<0.5)graphics.DrawRectangle(Pens.Blue,x,y,t,t);
// // if(water_depth[x,y]>=0.5)graphics.DrawRectangle(Pens.DarkBlue,x,y,t,t);
// //
//
// if(menuItem3.Checked==true&&water_depth[x,y]>water_depth_erosion_threshold)//MIN_Q)//||discharge[x,y]>0)
// {
// z=0;
// z=(int)(water_depth[x,y]*/*700*/125);
// //z=(int)(max_flow[x,y,3]*10);
// if(z<0)z=0;
// if(z>254)z=254;
//
// greencol=255-z;
// redcol=z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
//
// }
//
// if(menuItem4.Checked==true)
// {
// tomsedi+=(init_elevs[x,y]-elev[x,y]);
// tomsedi-=(Vsusptot[x,y])/(DX*DX);
// if(init_elevs[x,y]-elev[x,y]>0.001) //eroding
// {
// z=(int)((init_elevs[x,y]-elev[x,y])*256);
// if(z<0)z=0;
// if(z>254)z=254;
// greencol=255-z;
// redcol=z;
// // red green blue
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(255,greencol,greencol));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
//
// if(init_elevs[x,y]-elev[x,y]<-0.001) //depositing
// {
// z=(int)((elev[x,y]-init_elevs[x,y])*256);
// if(z<0)z=0;
// if(z>254)z=254;
// greencol=z;
// redcol=255-z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,255,redcol));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
//
// // if(init_elevs[x,y]-elev[x,y]>0.0001&&init_elevs[x,y]-elev[x,y]<0.1)graphics.DrawRectangle(Pens.Yellow,x*t,y*t,t,t);
// // if(init_elevs[x,y]-elev[x,y]>0.1&&init_elevs[x,y]-elev[x,y]<0.2)graphics.DrawRectangle(Pens.Orange,x*t,y*t,t,t);
// // if(init_elevs[x,y]-elev[x,y]>0.2&&init_elevs[x,y]-elev[x,y]<10)graphics.DrawRectangle(Pens.Red,x*t,y*t,t,t);
// // if(init_elevs[x,y]-elev[x,y]<-0.0001&&init_elevs[x,y]-elev[x,y]>-0.1)graphics.DrawRectangle(Pens.LightGreen,x*t,y*t,t,t);
// // if(init_elevs[x,y]-elev[x,y]<-0.1&&init_elevs[x,y]-elev[x,y]>-0.2)graphics.DrawRectangle(Pens.Green,x*t,y*t,t,t);
// // if(init_elevs[x,y]-elev[x,y]<-0.2&&init_elevs[x,y]-elev[x,y]>-10)graphics.DrawRectangle(Pens.DarkGreen,x*t,y*t,t,t);
//
//
// }
//
// if(menuItem5.Checked==true)
// {
// if(index[x,y]!=-9999)
// {
// z=(int)(veg[x,y,1]*256);
// if(z<0)z=0;
// if(z>254)z=254;
// greencol=z;
// redcol=255-z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,255,redcol));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
//
//
// // if(tot==0)graphics.DrawRectangle(Pens.Green,x*t,y*t,t,t);
// // if(tot==1)graphics.DrawRectangle(Pens.DarkBlue,x*t,y*t,t,t);
// // if(tot==2)graphics.DrawRectangle(Pens.Blue,x*t,y*t,t,t);
// // if(tot==3)graphics.DrawRectangle(Pens.LightBlue,x*t,y*t,t,t);
// // if(tot==4)graphics.DrawRectangle(Pens.White,x*t,y*t,t,t);
// // if(tot==5)graphics.DrawRectangle(Pens.LightGray,x*t,y*t,t,t);
// // if(tot==6)graphics.DrawRectangle(Pens.Gray,x*t,y*t,t,t);
// // if(tot==7)graphics.DrawRectangle(Pens.DarkGray,x*t,y*t,t,t);
// // if(tot==8)graphics.DrawRectangle(Pens.Black,x*t,y*t,t,t);
// // if(tot==9)graphics.DrawRectangle(Pens.DarkViolet,x*t,y*t,t,t);
// // if(tot==10)graphics.DrawRectangle(Pens.Brown,x*t,y*t,t,t);
// }
// }
//
// if(menuItem6.Checked==true&&TRACERS>1)
// {
// if(index[x,y]!=-9999)
// {
// if(grain[index[x,y],1,1]>0
// ||grain[index[x,y],2,1]>0
// ||grain[index[x,y],3,1]>0
// ||grain[index[x,y],4,1]>0
// ||grain[index[x,y],5,1]>0
// ||grain[index[x,y],6,1]>0
// ||grain[index[x,y],7,1]>0
// ||grain[index[x,y],8,1]>0
// ||grain[index[x,y],9,1]>0)
// {
//
//
// ztemp=0;
// for(n=1;n254)z=254;
// greencol=255-z;
// redcol=z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(255,greencol,redcol));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
// }
// }
//
//
//
// // now to draw second teir
//
//
// if(menuItem7.Checked==true&&edge[x,y]>-9999)
// {
//
// if(edge[x,y]>0) //inside
// {
// z=(int)((edge[x,y])*500);
// if(z<0)z=0;
// if(z>254)z=254;
// greencol=255-z;
// redcol=z;
// // red green blue
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(255,greencol,greencol));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
//
// if(edge[x,y]<0) //outside
// {
// z=(int)((0-edge[x,y])*500);
// if(z<0)z=0;
// if(z>254)z=254;
// greencol=z;
// redcol=255-z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,255,redcol));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
//
//// z=254;
//// //z=(int)((max_flow[x,y,0]*25)/(water_depth[x,y]*DX));
//// //z=(int)(water_depth[x,y]*700);
//// if(z<0)z=0;
//// if(z>254)z=254;
//// greencol=255-z;
//// redcol=z;
////
//// if(edge[x,y]==0)
//// {
//// SolidBrush brush = new SolidBrush(Color.Red);
//// graphics.FillRectangle(brush,x*t,y*t,t,t);
//// }
////
//// if(edge[x,y]>0)
//// {
//// SolidBrush brush = new SolidBrush(Color.Green);
//// graphics.FillRectangle(brush,x*t,y*t,t,t);
//// }
////
//// if(edge[x,y]<0)
//// {
//// SolidBrush brush = new SolidBrush(Color.Yellow);
//// graphics.FillRectangle(brush,x*t,y*t,t,t);
//// }
//
// }
//
// if(menuItem8.Checked==true)
// {
//
//
// //// if(init_elevs[x,y]-elev[x,y]>0.0001&&init_elevs[x,y]-elev[x,y]<0.1)graphics.DrawRectangle(Pens.Yellow,x*t,y*t+ymax,t,t);
// //// if(init_elevs[x,y]-elev[x,y]>0.1&&init_elevs[x,y]-elev[x,y]<0.2)graphics.DrawRectangle(Pens.Orange,x*t,y*t+ymax,t,t);
// //// if(init_elevs[x,y]-elev[x,y]>0.2&&init_elevs[x,y]-elev[x,y]<10)graphics.DrawRectangle(Pens.Red,x*t,y*t+ymax,t,t);
// //// if(init_elevs[x,y]-elev[x,y]<-0.0001&&init_elevs[x,y]-elev[x,y]>-0.1)graphics.DrawRectangle(Pens.LightGreen,x*t,y*t+ymax,t,t);
// //// if(init_elevs[x,y]-elev[x,y]<-0.1&&init_elevs[x,y]-elev[x,y]>-0.2)graphics.DrawRectangle(Pens.Green,x*t,y*t+ymax,t,t);
// //// if(init_elevs[x,y]-elev[x,y]<-0.2&&init_elevs[x,y]-elev[x,y]>-10)graphics.DrawRectangle(Pens.DarkGreen,x*t,y*t+ymax,t,t);
//
// if(water_depth[x,y]>0)
// {
// tot=(int)flow_dir[x,y,1];
// //if(tot==0)graphics.DrawRectangle(Pens.Green,x*t,y*t,t,t);
// // if(tot==1)graphics.DrawRectangle(Pens.Red,x*t,y*t,t,t);
// // if(tot==2)graphics.DrawRectangle(Pens.Blue,x*t,y*t,t,t);
// // if(tot==3)graphics.DrawRectangle(Pens.Yellow,x*t,y*t,t,t);
// // if(tot==4)graphics.DrawRectangle(Pens.Black,x*t,y*t,t,t);
// // if(tot==5)graphics.DrawRectangle(Pens.Orange,x*t,y*t,t,t);
// // if(tot==6)graphics.DrawRectangle(Pens.Gray,x*t,y*t,t,t);
// // if(tot==7)graphics.DrawRectangle(Pens.Pink,x*t,y*t,t,t);
// // if(tot==8)graphics.DrawRectangle(Pens.Green,x*t,y*t,t,t);
// //if(tot==9)graphics.DrawRectangle(Pens.DarkViolet,x*t,y*t,t,t);
// //if(tot==10)graphics.DrawRectangle(Pens.Brown,x*t,y*t,t,t);
//
// double slopemax=0;
// double slopesum=0;
// int slopenum=0;
// double ht=elev[x,y];
// double tot_ht=(elev[x,y]+water_depth[x,y]);
// int dir=0;
//
// // if(elev[x-1,y-1]0)
// // {
// // slopesum+=((ht-elev[x-1,y-1])/root);
// // slopenum++;
// // if(((ht-elev[x-1,y-1])/root)>slopemax)
// // {
// // slopemax=((ht-elev[x-1,y-1])/root);
// // dir=8;
// // }
// // if(dir==tot)slopemax=((ht-elev[x-1,y-1])/root);
// // }
// // if(elev[x,y-1]0)
// // {
// // slopesum+=((ht-elev[x,y-1])/DX);
// // slopenum++;
// // if(((ht-elev[x,y-1])/DX)>slopemax)
// // {
// // dir=1;
// // slopemax=((ht-elev[x,y-1])/DX);
// // }
// // if(dir==tot)slopemax=((ht-elev[x,y-1])/DX);
// // }
// // if(elev[x+1,y-1]0)
// // {
// // slopesum+=((ht-elev[x+1,y-1])/root);
// // slopenum++;
// // if(((ht-elev[x+1,y-1])/root)>slopemax)
// // {
// // slopemax=((ht-elev[x+1,y-1])/root);
// // dir=2;
// // }
// // if(dir==tot)slopemax=((ht-elev[x+1,y-1])/root);
// // }
// // if(elev[x+1,y]0)
// // {
// // slopesum+=((ht-elev[x+1,y])/DX);
// // slopenum++;
// // if(((ht-elev[x+1,y])/DX)>slopemax)
// // {
// // slopemax=((ht-elev[x+1,y])/DX);
// // dir=3;
// // }
// // if(dir==tot)slopemax=((ht-elev[x+1,y])/DX);
// // }
// // if(elev[x+1,y+1]0)
// // {
// // slopesum+=((ht-elev[x+1,y+1])/root);
// // slopenum++;
// // if(((ht-elev[x+1,y+1])/root)>slopemax)
// // {
// // slopemax=((ht-elev[x+1,y+1])/root);
// // dir=4;
// // }
// // if(dir==tot)slopemax=((ht-elev[x+1,y+1])/root);
// // }
// // if(elev[x,y+1]0)
// // {
// // slopesum+=((ht-elev[x,y+1])/DX);
// // slopenum++;
// // if(((ht-elev[x,y+1])/DX)>slopemax)
// // {
// // slopemax=((ht-elev[x,y+1])/DX);
// // dir=5;
// // }
// // if(dir==tot)slopemax=((ht-elev[x,y+1])/DX);
// // }
// // if(elev[x-1,y+1]0)
// // {
// // slopesum+=((ht-elev[x-1,y+1])/root);
// // slopenum++;
// // if(((ht-elev[x-1,y+1])/root)>slopemax)
// // {
// // slopemax=((ht-elev[x-1,y+1])/root);
// // dir=6;
// // }
// // if(dir==tot)slopemax=((ht-elev[x-1,y+1])/root);
// // }
// // if(elev[x-1,y]0)
// // {
// // slopesum+=((ht-elev[x-1,y])/DX);
// // slopenum++;
// // if(((ht-elev[x-1,y])/DX)>slopemax)
// // {
// // slopemax=((ht-elev[x-1,y])/DX);
// // dir=7;
// // }
// // if(dir==tot)slopemax=((ht-elev[x-1,y])/DX);
// // }
//
// // if(dir==tot)graphics.DrawRectangle(Pens.Red,x*t,y*t,t,t);
// // if(tot!=dir)graphics.DrawRectangle(Pens.Blue,x*t,y*t,t,t);
// // if(flow_dir[x,y,0]<1)graphics.DrawRectangle(Pens.Yellow,x*t,y*t,t,t);
//
//
// if(water_depth[x,y]>0&&water_depth[x-1,y-1]>0&&(water_depth[x,y]+elev[x,y])>(water_depth[x-1,y-1]+elev[x-1,y-1]))
// {
// slopesum+=(((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y-1]+elev[x-1,y-1]))/root);
// slopenum++;
// if((((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y-1]+elev[x-1,y-1]))/root)>slopemax)slopemax=(((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y-1]+elev[x-1,y-1]))/root);
// }
//
// if(water_depth[x,y]>0&&water_depth[x,y-1]>0&&(water_depth[x,y]+elev[x,y])>(water_depth[x,y-1]+elev[x,y-1]))
// {
// slopesum+=(((water_depth[x,y]+elev[x,y])-(water_depth[x,y-1]+elev[x,y-1]))/DX);
// slopenum++;
// if((((water_depth[x,y]+elev[x,y])-(water_depth[x,y-1]+elev[x,y-1]))/DX)>slopemax)slopemax=(((water_depth[x,y]+elev[x,y])-(water_depth[x,y-1]+elev[x,y-1]))/DX);
// }
//
// if(water_depth[x,y]>0&&water_depth[x+1,y-1]>0&&(water_depth[x,y]+elev[x,y])>(water_depth[x+1,y-1]+elev[x+1,y-1]))
// {
// slopesum+=(((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y-1]+elev[x+1,y-1]))/root);
// slopenum++;
// if((((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y-1]+elev[x+1,y-1]))/root)>slopemax)slopemax=(((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y-1]+elev[x+1,y-1]))/root);
// }
//
// if(water_depth[x,y]>0&&water_depth[x+1,y]>0&&(water_depth[x,y]+elev[x,y])>(water_depth[x+1,y]+elev[x+1,y]))
// {
// slopesum+=(((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y]+elev[x+1,y]))/DX);
// slopenum++;
// if((((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y]+elev[x+1,y]))/DX)>slopemax)slopemax=(((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y]+elev[x+1,y]))/DX);
// }
//
// if(water_depth[x,y]>0&&water_depth[x+1,y+1]>0&&(water_depth[x,y]+elev[x,y])>(water_depth[x+1,y+1]+elev[x+1,y+1]))
// {
// slopesum+=(((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y+1]+elev[x+1,y+1]))/root);
// slopenum++;
// if((((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y+1]+elev[x+1,y+1]))/root)>slopemax)slopemax=(((water_depth[x,y]+elev[x,y])-(water_depth[x+1,y+1]+elev[x+1,y+1]))/root);
// }
//
// if(water_depth[x,y]>0&&water_depth[x,y+1]>0&&(water_depth[x,y]+elev[x,y])>(water_depth[x,y+1]+elev[x,y+1]))
// {
// slopesum+=(((water_depth[x,y]+elev[x,y])-(water_depth[x,y+1]+elev[x,y+1]))/DX);
// slopenum++;
// if((((water_depth[x,y]+elev[x,y])-(water_depth[x,y+1]+elev[x,y+1]))/DX)>slopemax)slopemax=(((water_depth[x,y]+elev[x,y])-(water_depth[x,y+1]+elev[x,y+1]))/DX);
// }
//
// if(water_depth[x,y]>0&&water_depth[x-1,y+1]>0&&(water_depth[x,y]+elev[x,y])>(water_depth[x-1,y+1]+elev[x-1,y+1]))
// {
// slopesum+=(((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y+1]+elev[x-1,y+1]))/root);
// slopenum++;
// if((((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y+1]+elev[x-1,y+1]))/root)>slopemax)slopemax=(((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y+1]+elev[x-1,y+1]))/root);
// }
//
// if(water_depth[x,y]>0&&water_depth[x-1,y]>0&&(water_depth[x,y]+elev[x,y])>(water_depth[x-1,y]+elev[x-1,y]))
// {
// slopesum+=(((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y]+elev[x-1,y]))/DX);
// slopenum++;
// if((((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y]+elev[x-1,y]))/DX)>slopemax)slopemax=(((water_depth[x,y]+elev[x,y])-(water_depth[x-1,y]+elev[x-1,y]))/DX);
// }
// if(slopenum<1)slopenum=1;// prevent / by 0 error
//
//
// z=0;
// z=(int)((slopesum/slopenum)*water_depth[x,y]*1000);
// //z=(int)(slopemax*water_depth[x,y]*1000);
// //z=(int)(water_depth[x,y]*700);
// if(z<0)z=0;
// if(z>254)z=254;
// //if(z>100)z=254;
// greencol=255-z;
// redcol=z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
//
// }
//
// }
//
// if(menuItem9.Checked==true)
// {
// if(index[x,y]!=-9999)
// {
//
// tot_max=d50(index[x,y])*2000;
// //Console.WriteLine((Convert.ToString(tot_max)));
//
// tot=(int)tot_max;
// if(tot>255)tot=255;
// if(tot<0)tot=0;
//
// // if(grain[index[x,y],0,0]>0.19)
// // {
// // tot=0;
// // }
//
//
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(255-(tot*1),255-(tot*1),255-(tot*1)));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
//
// }
// }
//
//
// if(menuItem10.Checked==true&&TRACERS>1)
// {
// if(index[x,y]!=-9999&&grain[index[x,y],1,1]>0)
// {
// ztemp=0;
// for(n=1;n254)z=254;
// greencol=255-z;
// redcol=z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(255,greencol,redcol));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
// }
//
// if(menuItem26.Checked==true)
// {
// if(index[x,y]!=-9999)
// {
// //elev[x,y]=elev[x,y]-0.005; // removed MJ 23/03/05, to be consistent with slope calc in erode()
// if (water_depth[x,y] > 0.0&&elev[x,y]<=elev[x,y-1]&&elev[x,y]<=elev[x+1,y-1]&&elev[x,y]<=elev[x+1,y]&&elev[x,y]<=elev[x+1,y+1]&&elev[x,y]<=elev[x,y+1]&&elev[x,y]<=elev[x-1,y+1]&&elev[x,y]<=elev[x-1,y]&&elev[x,y]<=elev[x-1,y-1])
// {
// z=(250);
//
// if(z<0)z=0;
// if(z>254)z=254;
//
// greencol=255-z;
// redcol=z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
// //elev[x,y]=elev[x,y]+0.005; // removed MJ 23/03/05, to be consistent with slope calc in erode()
// }
// }
//
// if(menuItem27.Checked==true)
// {
// if(index[x,y]!=-9999)
// {
// if (Csusptot[x,y] > 0.0)
// {
// z=(int)(Csusptot[x,y]*25600);
// if(z<0)z=0;
// if(z>254)z=254;
//
// greencol=255-z;
// redcol=z;
//
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
// }
// }
//
// if(menuItem28.Checked==true)
// {
// if(index[x,y]!=-9999)
// {
// if (Vsusptot[x,y] > 0.0)
// {
// z=(int)(Vsusptot[x,y]*50);
// if(z<0)z=0;
// if(z>254)z=254;
// greencol=255-z;
// redcol=z;
// SolidBrush brush = new SolidBrush(Color.FromArgb(redcol,greencol,255));
// graphics.FillRectangle(brush,x*t,y*t,t,t);
// }
// }
// }
//
//
// }
// }
//
// this.QsStatusPanel.Text=string.Format("Qs = {0:F8}",tomsedi*DX*DX);
//
// }
void fill_pits()
{
int x,y,dir,x2=0,y2=0, inc;
double lowest=10000, highest=0;
double[,] pool_temp;
pool_temp=new Double[xmax+1,ymax+1];
for(x=1;x<(xmax);x++)
{
inc=1;
while(cross_scan[x,inc]>0)
{
y=cross_scan[x,inc];
inc++;
if(water_depth[x,y]>0)
{
pool_temp[x,y]=0;
lowest=10000;
highest=0;
for (dir=1;dir<=8;dir++)
{
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if(elev[x,y]+pool_depth[x,y]elev[x2,y2]+pool_depth[x2,y2])
{
if(elev[x2,y2]+pool_depth[x2,y2]>highest)highest=elev[x2,y2]+pool_depth[x2,y2];
}
}
// amount that pits should be filled or lowered by (always more loweredby) should be same/more than the erode/depo limit, otherwuse you can get pits eroded faster than they can be filled in
if(lowest!=10000&&lowest>(elev[x,y]+pool_depth[x,y]))pool_temp[x,y]+=ERODEFACTOR;//=lowest-(elev[x,y]+pool_depth[x,y]);
if(highest!=0&&highest0)
{
y=cross_scan[x,inc];
inc++;
if(water_depth[x,y]>0)
{
pool_depth[x,y]+=pool_temp[x,y];
if(pool_depth[x,y]<0)pool_depth[x,y]=0;
if(pool_depth[x,y]>water_depth[x,y])pool_depth[x,y]=water_depth[x,y];
}
}
}
}
void erode()
{
double tot_ht, ht, factor=0, slopemax=0,slopesum=0, amount_to_add=0, depth, tempb, tempbmax=0;
int x=0,y,n,inc, loopinc,q,xtemp,ytemp,temp_centre,p,slopenum;
double depth_threshold=water_depth_erosion_threshold; // was 0.001
double[] gtot,gtot2;
gtot = new Double[20];
gtot2 = new Double[20];
/** additional suspended sediment variables (MJ 16/02/05) **/
int dir,x2,y2;
int xyindex;
int Ucount;
double Usum,Umax;
double coeff;
double Vouttot,Voutcoeff;
double[] U = new Double[9];
double Csuspmax = 0.01;
double Vsusptemp,Vsuspmax;
double Vdir,Vpdir,Vpdrop,Vsurplus;
double gsusptot;
/** end of additional suspended sediment variables **/
// WriteSedFile("Start_erode()");
tempb=0;
for(n=0;n<=G_MAX;n++)
{
gtot[n]=0;
gtot2[n]=0;
}
double tempbcounter=0;
double tempbsubtotal=0;
do
{
//time_factor=60;
tempb=0;
tempbmax=0;
for(x=0;x<=grain_array_tot;x++)
{
for(y=0;y<=G_MAX;y++)
{
for(p=0;p<=(TRACERS-1);p++)
{
temp[x,y,p]=0;
}
}
}
/**
** START of additional suspended sediment code **
**
** The following lines are used to initialize the temporary suspended
** seds arrays. They are used later to temporarily store sediment volumes,
** before updating the official arrays Vsusp and Vsupstot.
**
** Added by MJ 16/02/05
** Latest change by MJ 09/05/05
**/
for (y=1; y<=ymax; y++)
{
for (x=1; x<=xmax; x++)
{
//Tau[x,y] = 0.0;
tempsusptot[x,y] = 0.0;
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
tempsusp[x,y,n,p] = 0.0;
}
}
}
}
}
/** end of additional suspended sediment code **/
// WriteSedFile("after_initialize");
// adding material in here...
// reorganized MJ 09/05/05
//
if (reach_mode_box.Checked==true)
{
for (n=0; n<=number_of_points-1; n++)
{
x = inpoints[n,0];
y = inpoints[n,1];
int tempn,n2;
for (tempn=5; tempn<=13; tempn++)
{
if (index[x,y] == -9999) addGS(x,y);
amount_to_add = Math.Abs(inputfile[n,(int)((cycle-init_cycle)/input_time_step),tempn]);
amount_to_add = amount_to_add / (DX*DX); // divide by grid cell size
amount_to_add /= (input_time_step*60); // turn from days to secs
amount_to_add = amount_to_add*time_factor; // convert rate into volume
//Console.WriteLine(Convert.ToString(amount_to_add));
n2 = tempn-4;
if(isSuspended[n2])
{
// Vsusp[x,y,n2,0] += amount_to_add*(DX*DX);
// Vsusptot[x,y] += amount_to_add*(DX*DX);
tempsusp[x,y,n2,0] += amount_to_add*(DX*DX);
tempsusptot[x,y] += amount_to_add*(DX*DX);
}
else
{
temp[index[x,y],n2,0] += amount_to_add;
}
}
}
}
// WriteSedFile("after_influx");
//max=0;
tempbcounter=0;
tempbsubtotal=0;
for(y=1;y0)
{
x=down_scan[y,inc];
inc++;
/** check to see if under water **/
if(water_depth[x,y]>depth_threshold&&x>1&&x0&&elev[x,y]>bedrock[x,y])erode_w(x,y,water_depth[x,y],1,slopesum);
/************************************************************************************************/
/* calls erode 3, with amount, dist category, grid category (for grain sizes) and x+y's */
erode3(0,3,x,y);
erode3(1,4,x,y);
erode3(2,5,x,y);
erode3(3,6,x,y);
erode3(4,7,x,y);
erode3(5,8,x,y);
erode3(6,9,x,y);
erode3(7,10,x,y);
erode3(8,11,x,y);
erode3(9,12,x,y);
erode3(10,13,x,y);
/*** try new tempb approach.... *******************************************/
tempb=0;
if(index[x,y]!=-9999)
{
for(loopinc=1;loopinc<=G_MAX;loopinc++)
{
for(p=0;p<=(TRACERS-1);p++)
{
tempb+=temp[index[x,y],loopinc,p];
tempbsubtotal+=temp[index[x,y],loopinc,p];
}
}
}
tempbcounter++;
if(tempb<0)tempb=0-tempb;
if(tempb>tempbmax)
{
if(tempbmax>ERODEFACTOR)this.tempdata1.Text=Convert.ToString(x);
if(tempbmax>ERODEFACTOR)this.tempdata2.Text=Convert.ToString(y);
tempbmax=tempb;
}
}
}
}
//IMPORTANT - trying to increase time step here..
time_factor=time_factor*1.5;
// or trying to decrease it too!
if(tempbmax>ERODEFACTOR&&time_factor>min_time_step)time_factor=time_factor/2;
} while (tempbmax>ERODEFACTOR&&time_factor>min_time_step);
// WriteSedFile("after_entrainment");
// add in recirculating sediment.
if(recirculatebox.Checked==true&&reach_mode_box.Checked==true)
{
int tempn;
for(n=0;n<=number_of_points-1;n++)
{
x=inpoints[n,0];
y=inpoints[n,1];
for(tempn=5;tempn<=13;tempn++)
{
if(index[x,y]==-9999)addGS(x,y);
temp[index[x, y], tempn - 4, 0] += (temp_grain[tempn - 4] / number_of_points)*double.Parse(propremaining.Text);
}
}
for(tempn=5;tempn<=13;tempn++)
{
temp_grain[tempn-4]=0;
}
}
// WriteSedFile("after_recirculate");
// adding in tracer sediment,
// also has to update the elevations and temp values just in case they are missed by the
// main erode loops. e.g adding material outside of scanned zone.
if(TRACERS==2)
{
for(n=1;n<=tot_number_of_tracer_points;n++)
{
// same as above but adding tracer material
amount_to_add=0;
x=Convert.ToInt32(tracerinput[n,1]);
y=Convert.ToInt32(tracerinput[n,2]);
factor=tracerinput[n,3];
amount_to_add=tracerhydrograph[(int)(cycle/60),1]*factor;
amount_to_add=amount_to_add/(DX*DX);
amount_to_add=amount_to_add/3600;
if(index[x,y]==-9999)addGS(x,y);
temp[index[x,y],Convert.ToInt32(tracerinput[n,4]),1]+=amount_to_add*time_factor;
// now update values incase missed by main loop below.
grain[index[x,y],Convert.ToInt32(tracerinput[n,4]),1]+=temp[index[x,y],Convert.ToInt32(tracerinput[n,4]),1];
if(x 0)
// {
// x = down_scan[y,inc];
// if (water_depth[x,y] >= 0.0)
// {
// Vsuspmax = Csuspmax * (water_depth[x,y] * DX * DX);
// if (Vsusptot[x,y] > Vsuspmax)
// {
// // carrying too much sediment, even without additional entrainment
// // this is due to falling water levels (proabably)
// // surplus of each fraction will be added to temp[x,y,p]
// Vsurplus = Vsusptot[x,y] - Vsuspmax;
// coeff = Vsurplus / Vsusptot[x,y];
// if (index[x,y] == -9999) addGS(x,y);
// xyindex = index[x,y];
// for (p=0;p<=(TRACERS-1);p++)
// {
// Vpdrop = coeff * Vsusp[x,y,p];
// if((Vpdrop/(DX*DX))>0.001)Vpdrop=0.001*(DX*DX); // tjc - stop too much dropping out.
// temp[xyindex,1,p] += Vpdrop / (DX*DX);
// Vsusp[x,y,p] -= Vpdrop;
// Vsusptot[x,y] -= Vpdrop;
// }
// }
// }
// inc++; // go to next element in downscan[y,inc]
// }
// }
// check for excess concentrations after entrainment
for (y=1;y<=ymax;y++)
{
inc = 1;
while (down_scan[y,inc] > 0)
{
x = down_scan[y,inc];
if (tempsusptot[x,y] > 0.0)
{
if (water_depth[x,y] > 0.0)
{
Vsuspmax = Csuspmax * (water_depth[x,y] * DX * DX);
Vsusptemp = Vsusptot[x,y] + tempsusptot[x,y];
if (Vsusptemp > Vsuspmax)
{
// entrained too much sediment in tempsusptot
// surplus of each fraction will be added to temp[x,y,p]
Vsurplus = Vsusptemp - Vsuspmax;
if (Vsurplus > tempsusptot[x,y]) Vsurplus = tempsusptot[x,y];
coeff = Vsurplus / tempsusptot[x,y];
if (index[x,y] == -9999) addGS(x,y);
xyindex = index[x,y];
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
Vpdrop = coeff * tempsusp[x,y,n,p];
temp[xyindex,n,p] += Vpdrop / (DX*DX); // bug fix MJ 06/07/05
tempsusp[x,y,n,p] -= Vpdrop;
tempsusptot[x,y] -= Vpdrop;
}
}
}
}
}
else
{
// this should never be activated as it implies entrainment from dry cell
// but if it does happen, this code will drop all the sediment back
Console.WriteLine("!! Tried to entrain susp sed from dry cell");
if (index[x,y] == -9999) addGS(x,y);
xyindex = index[x,y];
tempsusptot[x,y] = 0.0;
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
temp[xyindex,n,p] += tempsusp[x,y,n,p] / (DX*DX); // bug fix MJ 06/07/05
tempsusp[x,y,n,p] = 0.0;
}
}
}
}
}
inc++; // go to next element in downscan[y,inc]
}
}
// WriteSedFile("after_drop_excess");
// update Vsusp to account for susp entrainment
for (y=1;y<=ymax;y++)
{
inc = 1;
while (down_scan[y,inc] > 0)
{
x = down_scan[y,inc];
if (tempsusptot[x,y] > 0.0)
{
Vsusptot[x,y] += tempsusptot[x,y];
tempsusptot[x,y] = 0.0; // clear for re-use
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
Vsusp[x,y,n,p] += tempsusp[x,y,n,p];
tempsusp[x,y,n,p] = 0.0; // clear for re-use
}
}
}
}
inc++; // go to next element in downscan[y,inc]
}
}
// WriteSedFile("after_update_Vsusp_1");
// distribute susp seds
for (y=1;y<=ymax;y++)
{
inc = 1;
while (down_scan[y,inc] > 0)
{
x = down_scan[y,inc];
if ((x < xmax) && (water_depth[x,y] > depth_threshold) && (Vsusptot[x,y] > 0))
{
// determine velocities
coeff = water_depth[x,y] * DX;
Umax = 0.0;
Usum = 0.0;
Ucount = 0;
for (dir=1;dir<=8;dir++)
{
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if ( (max_flow[x,y,dir] > 0.00000000001) // check that there is maxflow in that dir
&& (water_depth[x2,y2] > depth_threshold) // and there is water depth
&& (Vsusptot[x2,y2] < ((Csuspmax) * (water_depth[x2,y2] * DX * DX))) // and not too concentrated in recieving cell
// && (elev[x,y]+water_depth[x,y])>(elev[x2,y2]+water_depth[x2,y2]) // and +ve water surface slope
// && (elev[x,y]+water_depth[x,y])>(elev[x2,y2]) // and +ve water to bed slope..
)
{
Ucount++;
U[dir] = max_flow[x,y,dir] / coeff;
if (U[dir] > Umax) Umax = U[dir];
Usum += U[dir];
}
else U[dir] = 0;
}
if (Usum > 0.000000000001)
{
// determine volume to be moved out
Voutcoeff = (Usum*time_factor) / DX;
if (Voutcoeff > 0.9999) Voutcoeff = 0.9999; // MJ 23/03/05 to avoid problems later on
// distribute according to velocities
for (dir=1;dir<=8;dir++)
{
if (U[dir] > 0.000000000000001)
{
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if ((x2 > 0) && (y2 > 0) && (y2 <= ymax))
{
if (index[x2,y2] == -9999) addGS(x2,y2);
coeff = U[dir] / Usum;
Vdir = coeff * Voutcoeff * Vsusptot[x,y];
tempsusptot[x,y] -= Vdir;
tempsusptot[x2,y2] += Vdir;
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
Vpdir = coeff * Voutcoeff * Vsusp[x,y,n,p];
tempsusp[x,y,n,p] -= Vpdir;
tempsusp[x2,y2,n,p] += Vpdir;
}
}
}
}
}
}
}
}
inc++; // go to next element in downscan[y,inc]
}
}
// WriteSedFile("after_distribute");
// update Vsusp to account for susp movement
for (y=1;y<=ymax;y++)
{
inc = 1;
while (down_scan[y,inc] > 0)
{
x = down_scan[y,inc];
if ((x < xmax) && (tempsusptot[x,y] != 0))
{
Vsusptot[x,y] += tempsusptot[x,y];
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
Vsusp[x,y,n,p] += tempsusp[x,y,n,p];
}
}
}
}
if (Vsusptot[x,y] < 0.0)
{
// needed for numerical stability
// Vsusptot can sometimes be - 1.0 x 10-15
// MJ 23/03/05 : extra note : this issue is solved when Voutcoeff < 1.0
Vsusptot[x,y] = 0.0;
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
Vsusp[x,y,n,p] = 0;
}
}
}
}
inc++; // go to next element in downscan[y,inc]
}
}
// WriteSedFile("after_update_Vsusp_2");
// add up susp seds at outflow (adjusted MJ 04/07/2005)
gsusptot = 0;
for (y=1;y<=ymax;y++)
{
if (tempsusptot[xmax,y] > 0)
{
gsusptot += tempsusptot[xmax,y];
for(n=0;n<=G_MAX;n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
gtot2[n] += tempsusp[xmax,y,n,p]/(DX*DX);
}
}
}
}
}
this.tempStatusPanel.Text=string.Format("Qss = {0:F8}",gsusptot/time_factor);
// WriteSedFile("after_update_outflow");
// drop susp sediments according to fall velocity
for (y=1;y<=ymax;y++)
{
inc = 1;
while (down_scan[y,inc] > 0)
{
x = down_scan[y,inc];
if (Vsusptot[x,y] > 0.000000000001)
{
if (index[x,y] == -9999) addGS(x,y);
xyindex = index[x,y];
if (water_depth[x,y] > depth_threshold)
{
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
coeff = (fallVelocity[n]*time_factor) / water_depth[x,y];
if(max_flow[x,y,0]/(DX*water_depth[x,y])>0.25)coeff=0; // TJC - 10/1/06 this part is so that it can only drop sediment if the velocity is below a threshold)
if (coeff > 1) coeff = 1;
for (p=0;p<=(TRACERS-1);p++)
{
Vpdrop = Vsusp[x,y,n,p] * coeff;
if (Vpdrop /(DX*DX) > 0.001) Vpdrop = 0.001 * (DX*DX);
temp[xyindex,n,p] += Vpdrop / (DX*DX); // bug fix MJ 06/07/05
Vsusp[x,y,n,p] -= Vpdrop;
Vsusptot[x,y] -= Vpdrop;
}
}
}
Csusptot[x,y] = Vsusptot[x,y] / (water_depth[x,y] * DX * DX);
}
else
// restructured this bit (MJ 07/06/05)
// previous version contained a bug here
// bug: Vsusptot[x,y] != sum Vsusp[x,y,n,p]
// don't why previous routine was wrong, nor why this works
// seems like it does exactly the same, but this one works
{
for (n=0; n<=G_MAX; n++)
{
if (isSuspended[n])
{
for (p=0; p<=(TRACERS-1); p++)
{
Vpdrop = Vsusp[x,y,n,p];
if (Vpdrop /(DX*DX) > 0.001) Vpdrop = 0.001 * (DX*DX);
temp[xyindex,n,p] += Vpdrop / (DX*DX); // bug fix MJ 06/07/05
Vsusp[x,y,n,p] -= Vpdrop;
Vsusptot[x,y] -= Vpdrop;
}
}
}
if (water_depth[x,y] > 0.0)
{
Csusptot[x,y] = Vsusptot[x,y] / (water_depth[x,y] * DX * DX);
}
else
{
Csusptot[x,y] = 0.0;
}
}
// else
// {
// for (n=0; n<=G_MAX; n++)
// {
// if (isSuspended[n])
// {
// for (p=0; p<=(TRACERS-1); p++)
// {
// if(Vsusp[x,y,n,p] / (DX*DX)>0.001) //tjc 11/3/05 to prevent too much dropping out at once..
// {
// Vpdrop = 0.001 * (DX*DX);
// Vsusp[x,y,n,p] -= Vpdrop;
// Vsusptot[x,y] -= Vpdrop;
// Csusptot[x,y] -= Vpdrop;
// temp[xyindex,n,p] += 0.001; // bug fix MJ 06/07/05
// }
// else
// {
// temp[xyindex,n,p] += Vsusp[x,y,n,p] / (DX*DX); // bug fix MJ 06/07/05
// Vsusp[x,y,n,p] = 0.0;
// Vsusptot[x,y] = 0.0;
// Csusptot[x,y] = 0.0;
// }
// }
// }
// }
// }
}
inc++; // go to next element in downscan[y,inc]
}
}
// WriteSedFile("after_drop_susp");
/** end of additional suspended sediment code **/
/* from here on is really only an update the values routine...*/
// restructured MJ 25/03/05
bool need_sorting;
for(y=1;y<=ymax;y++)
{
inc=1;
while(down_scan[y,inc]>0)
{
x=down_scan[y,inc];
if(index[x,y]!=-9999&&y<=ymax&&y>=1&&x>=1&&x<=xmax)
{
temp_centre=index[x,y];
need_sorting = false;
for(n=0;n<=G_MAX;n++)
{
for(p=0;p<=(TRACERS-1);p++)
{
if (temp[temp_centre,n,p] != 0.0)
{
grain[temp_centre,n,p]+=temp[temp_centre,n,p];
if(x0&&p==0)gtot[n]+=temp[temp_centre,n,p];
if(x==xmax)gtot2[n]+=temp[temp_centre,n,p];
//temp[temp_centre,n,p]=0; commented out on 18/7/05 - to allow temp to be used in lateral2
need_sorting = true;
}
}
}
if (need_sorting) sort_active2(x,y);
}
inc++; // go to next element in downscan[y,inc]
}
}
// WriteSedFile("after_sorting");
// update output fluxes
sediQ=0;
for(n=1;n<=G_MAX;n++)
{
temp_grain[n]=gtot2[n];
sediQ+=gtot2[n]*DX*DX;
globalsediq+=gtot2[n]*DX*DX;
sum_grain[n]+=gtot2[n]*DX*DX; // Gez
}
// now display sedi out bottom..
if(menuItem4.Checked==false)this.QsStatusPanel.Text=string.Format("Qs = {0:F8}",sediQ); // MJ 14/01/05
// WriteSedFile("End_erode()");
}
void erode_w(int x, int y, double depth, double slope, double slopesum)
// restructured by MJ 02/02/05
{
int n;
double slopesum2=0;
double slopesum3 = 0;
double qmax=0;
double k=0;
if (Tau[x,y]>0)
{
int dir,x2,y2;
int p,z;
double[] temp_dist;
temp_dist = new Double[11];
double rho = 1000.0;
double gravity = 9.8;
if (index[x,y] == -9999) addGS(x,y);
if(slope>0.01)slope=0.01; // dubious line.. maybee review..
double Di = 0.0;
double tau = Tau[x,y];
//double tau =rho*gravity*Math.Pow(slope,0.25)*Math.Pow(0.03,1.5)*Math.Pow((max_flow[x,y,0]/(depth*DX)),1.5);
//tau=tau*5;
// if(edge[x,y]<-0.0001)tau=tau/2;
// if(edge[x,y]>0.0001)tau=tau*1.5;
// if(tau<0)tau=0;
double U_star = Math.Pow(tau/rho,0.5);
double tau_ri = 0.0;
double Wi_star = 0.0;
double d_50 = d50(index[x,y]);
double Fs = sand_fraction(index[x,y]);
double Qbi = 0;
double temptot = 0;
double elevdiff = 0;
double a,b;
double coeff;
double[] bedslope, bedslope2, bedslope3;
bedslope = new double[11];
bedslope2 = new double[11];
bedslope3 = new double[11];
// interestingline..
//if(edge[x,y]>-1)tau=tau*(5*(1+edge[x,y]));
// works out how much should be eroded from the cell according to max slope & depth.
for (n=1;n<=9;n++)
{
if (n == 0) Di = d0;
if (n == 1) Di = d1;
if (n == 2) Di = d2;
if (n == 3) Di = d3;
if (n == 4) Di = d4;
if (n == 5) Di = d5;
if (n == 6) Di = d6;
if (n == 7) Di = d7;
if (n == 8) Di = d8;
if (n == 9) Di = d9;
tau_ri = (0.021+(0.015*Math.Exp(-20*Fs))) * (rho*gravity*d_50) * Math.Pow( (Di/d_50), (0.67/(1+Math.Exp(1.5-(Di/d_50)))) );
if ((tau/tau_ri) < 1.35)
{
Wi_star = 0.002 * Math.Pow(tau/tau_ri, 7.5);
}
else
{
Wi_star = 14 * Math.Pow(1-(0.894/Math.Pow(tau/tau_ri, 0.5)), 4.5);
}
Qbi = ( (Fi(index[x,y],n) * Math.Pow(U_star, 3)) / ((2.65-1)*gravity) ) * Wi_star;
temp_dist[n] = Qbi * time_factor; // not sure if it should have a *DX here..
//temp_dist[n] = Qbi * time_factor * DX; // I think it should MJ 05/02/05
// well it isnt!! TJC 05/04/05
if (temp_dist[n] < 0.0000000000001) temp_dist[n] = 0;
}
temp_dist[10] = 0;
// here to remove from veg layer..
if ((veg[x,y,1] > 0) && (tau > vegTauCrit))
{
temp_dist[0] = time_factor * Math.Pow(tau-vegTauCrit,1) * 0.000005;
// now to remove from veg layer..
//Console.WriteLine(Convert.ToString(temp_dist[0]));
veg[x,y,1] -= temp_dist[0];
if (veg[x,y,1] < 0) veg[x,y,1] = 0;
}
// now to determine if movement should be restricted due to veg...
if (veg[x,y,1] > 0.5)
{
temptot=0;
elevdiff=0;
// adds up total of material to be removed.. including calculating how much is there to be moved
for (n=1;n<=9;n++)
{
if (grain_tot(index[x,y],n)-temp_dist[n] < 0)
{
temp_dist[n] = grain_tot(index[x,y],n);
}
temptot += temp_dist[n];
}
// now checks if this removed from the cell would put it below the veg layer..
if (elev[x,y] - temptot <= veg[x,y,0])
{
// now remove from proportion that can be eroded..
// we can do this as we have the prop (in temptot) that is there to be eroded.
elevdiff = elev[x,y]-veg[x,y,0];
for (n=1;n<=9;n++)
{
temp_dist[n] = elevdiff * (temp_dist[n]/temptot);
if (elev[x,y] <= veg[x,y,0]) temp_dist[n] = 0;
}
}
}
k=0;
if(edge2[x,y]<0&&edge2[x,y]>-9999)Console.WriteLine("arse");
if(edge2[x,y]>0)// prevent /0 errors
//k=width[x,y]/(1/edge2[x,y]);// works out value that is moved according to curvature
k=edge2[x,y]*8;
//k=(2/(((2.131*Math.Pow(edge2[x,y],-1.0794))*DX)/(DX*width[x,y])));
//k*=2;
//k = Math.Pow(edge2[x, y], 0.7)*2; // liked this one..
if(k>0.5)k=0.5;
//if (k < 0.25) k = 0.25;
double bedfraction = 1/Math.Pow((1+Math.Pow(k,2)),0.5);
bedfraction = 1-k;
//bedfraction = 1;
//Console.WriteLine(Convert.ToString(k));
//if(bedfraction<0.5)bedfraction=0.5;
// determine local bed slopes
// here bedslope 2 uses the 'edge' variable gradient to also route a fraction according to lateral gradient.
for (n=1;n<=8;n++)
{
bedslope[n] = 0;
bedslope2[n] = 0;
bedslope2[n] = 0;
}
double pd=double.Parse(pitdepth.Text);
if ((elev[ x ,y-1] < elev[x,y]+(DX/pd))&&edge[ x ,y-1]>-9999&&edge[ x ,y-1] < edge[x,y]&&water_depth[x,y-1]>water_depth_erosion_threshold) bedslope2[1] = (((edge[x,y])-edge[x,y-1]) / DX);
if ((elev[x+1,y-1] < elev[x,y]+(root/pd))&&edge[x+1,y-1]>-9999&&edge[x+1,y-1] < edge[x,y]&&water_depth[x+1,y-1]>water_depth_erosion_threshold) bedslope2[2] = (((edge[x,y])-edge[x+1,y-1]) / root);
if ((elev[x+1,y] < elev[x,y]+(DX/pd))&&edge[x+1,y]>-9999&&edge[x+1, y ] < edge[x,y]&&water_depth[x+1,y]>water_depth_erosion_threshold) bedslope2[3] = (((edge[x,y])-edge[x+1,y]) / DX);
if ((elev[x+1,y+1] < elev[x,y]+(root/pd))&&edge[x+1,y+1]>-9999&&edge[x+1,y+1] < edge[x,y]&&water_depth[x+1,y+1]>water_depth_erosion_threshold) bedslope2[4] = (((edge[x,y])-edge[x+1,y+1]) / root);
if ((elev[x,y+1] < elev[x,y]+(DX/pd))&&edge[x,y+1]>-9999&&edge[ x ,y+1] < edge[x,y]&&water_depth[x,y+1]>water_depth_erosion_threshold) bedslope2[5] = (((edge[x,y])-edge[x,y+1]) / DX);
if ((elev[x-1,y+1] < elev[x,y]+(root/pd))&&edge[x-1,y+1]>-9999&&edge[x-1,y+1] < edge[x,y]&&water_depth[x-1,y+1]>water_depth_erosion_threshold) bedslope2[6] = (((edge[x,y])-edge[x-1,y+1]) / root);
if ((elev[x-1,y] < elev[x,y]+(DX/pd))&&edge[x-1,y]>-9999&&edge[x-1, y ] < edge[x,y]&&water_depth[x-1,y]>water_depth_erosion_threshold) bedslope2[7] = (((edge[x,y])-edge[x-1,y]) / DX);
if ((elev[x-1,y-1] < elev[x,y]+(root/pd))&&edge[x-1,y-1]>-9999&&edge[x-1,y-1] < edge[x,y]&&water_depth[x-1,y-1]>water_depth_erosion_threshold) bedslope2[8] = (((edge[x,y])-edge[x-1,y-1]) / root);
// bedslopes
bedslope3[1] += (elev[x, y] - elev[x, y - 1]) / DX;
bedslope3[2] += (elev[x, y] - elev[x + 1, y - 1]) / root;
bedslope3[3] += (elev[x, y] - elev[x + 1, y]) / DX;
bedslope3[4] += (elev[x, y] - elev[x + 1, y + 1]) / root;
bedslope3[5] += (elev[x, y] - elev[x, y + 1]) / DX;
bedslope3[6] += (elev[x, y] - elev[x - 1, y + 1]) / root;
bedslope3[7] += (elev[x, y] - elev[x - 1, y]) / DX;
bedslope3[8] += (elev[x, y] - elev[x - 1, y - 1]) / root;
/// try using discharge gradients...
///
double tot2 = 0;
double xplus = (left_out[x, y] - right_in[x, y]);
double xminus = (right_out[x, y] - left_in[x, y]);
double yplus = (up_out[x, y] - down_in[x, y]);
double yminus = (down_out[x, y] - up_in[x, y]);
if (xplus < 0) xplus = 0;
if (xminus < 0) xminus = 0;
if (yplus < 0) yplus = 0;
if (yminus < 0) yminus = 0;
if (xplus > 0)
{
double wtot = 0;
if (water_depth[x + 1, y - 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x + 1, y - 1]) / root;
if (water_depth[x + 1, y] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x + 1, y]) / DX;
if (water_depth[x + 1, y + 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x + 1, y + 1]) / root;
if (water_depth[x + 1, y - 1] > water_depth_erosion_threshold) bedslope[2] += xplus * ((((water_depth[x, y] + elev[x, y]) - elev[x + 1, y - 1]) / root) / wtot);
if (water_depth[x + 1, y] > water_depth_erosion_threshold) bedslope[3] += xplus * ((((water_depth[x, y] + elev[x, y]) - elev[x + 1, y]) / DX) / wtot);
if (water_depth[x + 1, y + 1] > water_depth_erosion_threshold) bedslope[4] += xplus * ((((water_depth[x, y] + elev[x, y]) - elev[x + 1, y + 1]) / root) / wtot);
}
if (xminus > 0)
{
double wtot = 0;
if (water_depth[x - 1, y - 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x - 1, y - 1]) / root;
if (water_depth[x - 1, y] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x - 1, y]) / DX;
if (water_depth[x - 1, y + 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x - 1, y + 1]) / root;
if (water_depth[x - 1, y - 1] > water_depth_erosion_threshold) bedslope[8] += xminus * ((((water_depth[x, y] + elev[x, y]) - elev[x - 1, y - 1]) / root) / wtot);
if (water_depth[x - 1, y] > water_depth_erosion_threshold) bedslope[7] += xminus * ((((water_depth[x, y] + elev[x, y]) - elev[x - 1, y]) / DX) / wtot);
if (water_depth[x - 1, y + 1] > water_depth_erosion_threshold) bedslope[6] += xminus * ((((water_depth[x, y] + elev[x, y]) - elev[x - 1, y + 1]) / root) / wtot);
}
if (yplus > 0)
{
double wtot = 0;
if (water_depth[x - 1, y - 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x - 1, y - 1]) / root;
if (water_depth[x, y - 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x, y - 1]) / DX;
if (water_depth[x + 1, y - 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x + 1, y - 1]) / root;
if (water_depth[x - 1, y - 1] > water_depth_erosion_threshold) bedslope[8] += yplus * ((((water_depth[x, y] + elev[x, y]) - elev[x - 1, y - 1]) / root) / wtot);
if (water_depth[x, y - 1] > water_depth_erosion_threshold) bedslope[1] += yplus * ((((water_depth[x, y] + elev[x, y]) - elev[x, y - 1]) / DX) / wtot);
if (water_depth[x + 1, y - 1] > water_depth_erosion_threshold) bedslope[2] += yplus * ((((water_depth[x, y] + elev[x, y]) - elev[x + 1, y - 1]) / root) / wtot);
}
if (yminus > 0)
{
double wtot = 0;
if (water_depth[x - 1, y + 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x - 1, y + 1]) / root;
if (water_depth[x, y + 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x, y + 1]) / DX;
if (water_depth[x + 1, y + 1] > water_depth_erosion_threshold) wtot += ((water_depth[x, y] + elev[x, y]) - elev[x + 1, y + 1]) / root;
if (water_depth[x - 1, y + 1] > water_depth_erosion_threshold) bedslope[6] += yminus * ((((water_depth[x, y] + elev[x, y]) - elev[x - 1, y + 1]) / root) / wtot);
if (water_depth[x, y + 1] > water_depth_erosion_threshold) bedslope[5] += yminus * ((((water_depth[x, y] + elev[x, y]) - elev[x, y + 1]) / DX) / wtot);
if (water_depth[x + 1, y + 1] > water_depth_erosion_threshold) bedslope[4] += yminus * ((((water_depth[x, y] + elev[x, y]) - elev[x + 1, y + 1]) / root) / wtot);
}
// and total bedslope and edge slope
slopesum = 0;
slopesum2= 0;
slopesum3 = 0;
for (n=1;n<=8;n++)
{
if(bedslope[n]<0)bedslope[n]=0;
if(bedslope2[n]<0)bedslope2[n]=0;
if (bedslope3[n] < 0) bedslope3[n] = 0;
//bedslope[n]+=(bedslope2[n]*0.000);
slopesum+=bedslope[n];
slopesum2+=bedslope2[n];
slopesum3 += bedslope3[n];
}
//bedfraction=0.5;
if(slopesum==0)bedfraction=1;
//bedfraction=1;
for(n=1;n<=9;n++)
{
//catch if, to see if there isactually any erosion in this size...
if (temp_dist[n] > 0)
{
// has to check to see whether it is bedslope determining tau. If so then has to route according to bedslope else you get problesm
if (bedslope_box.Checked == false)
{
// now distribute according to Q slopes
coeff = (temp_dist[n] * (bedfraction * 1)) / slopesum;
if (bedslope[1] > 0) dist[2, n] += coeff * bedslope[1];
if (bedslope[2] > 0) dist[3, n] += coeff * bedslope[2];
if (bedslope[3] > 0) dist[4, n] += coeff * bedslope[3];
if (bedslope[4] > 0) dist[5, n] += coeff * bedslope[4];
if (bedslope[5] > 0) dist[6, n] += coeff * bedslope[5];
if (bedslope[6] > 0) dist[7, n] += coeff * bedslope[6];
if (bedslope[7] > 0) dist[8, n] += coeff * bedslope[7];
if (bedslope[8] > 0) dist[1, n] += coeff * bedslope[8];
// dis according to lateral slopes
coeff = (temp_dist[n] * (1 - bedfraction)) / slopesum2;
if (bedslope2[1] > 0) dist[2, n] += coeff * bedslope2[1];
if (bedslope2[2] > 0) dist[3, n] += coeff * bedslope2[2];
if (bedslope2[3] > 0) dist[4, n] += coeff * bedslope2[3];
if (bedslope2[4] > 0) dist[5, n] += coeff * bedslope2[4];
if (bedslope2[5] > 0) dist[6, n] += coeff * bedslope2[5];
if (bedslope2[6] > 0) dist[7, n] += coeff * bedslope2[6];
if (bedslope2[7] > 0) dist[8, n] += coeff * bedslope2[7];
if (bedslope2[8] > 0) dist[1, n] += coeff * bedslope2[8];
}
// dis according to bed slopes
if (bedslope_box.Checked == true)
{
coeff = temp_dist[n] / slopesum3;
if (bedslope3[1] > 0) dist[2, n] += coeff * bedslope3[1];
if (bedslope3[2] > 0) dist[3, n] += coeff * bedslope3[2];
if (bedslope3[3] > 0) dist[4, n] += coeff * bedslope3[3];
if (bedslope3[4] > 0) dist[5, n] += coeff * bedslope3[4];
if (bedslope3[5] > 0) dist[6, n] += coeff * bedslope3[5];
if (bedslope3[6] > 0) dist[7, n] += coeff * bedslope3[6];
if (bedslope3[7] > 0) dist[8, n] += coeff * bedslope3[7];
if (bedslope3[8] > 0) dist[1, n] += coeff * bedslope3[8];
}
}
}
}
}
void erode2(int p, double t, double depth, double slope)
{
/* here, forme erode, the x,y co-ords of the cell to be eroded from are passed.
along with the direction to be eroded to, xinc, yinc, as wellas the pow er (t)
I've set the active layer, as a fixed size, (2*d84) or for this case approx
50cm. This aslways remains fixed (depth) and if depositing, any excess is moved down,
if eroding moved up into active layer. updating etc is going to be complex. can assume,
that as program will only allow 10% of depth eroded, 50cm means 5m deep flow, will probably never
happen */
/* this const, muller is Richards def, not other which is 0.4063 */
double v;
double muller=0.2593;
double manning=0.03;
double tcrit1=4;
double tcrit2=8;
double tcrit3=16;
double tcrit4=32;
double tcrit5=64;
double amount=0;
double amt0=0;
double amt1=0;
double amt2=0;
double amt3=0;
double amt4=0;
double amt5=0;
double amt6=0;
double amt7=0;
double amt8=0;
double amt9=0;
double amt10=0;
double ibr=0.01;
double Wr=0.5;
double Yr=0.1;
double Dr=0.0011;
double wo_constant=50000; /** wrong!!*/
double w=0;
double wo1=0;
double wo2=0;
double wo3=0;
double wo4=0;
double wo5=0;
double devils_fork0=0;
double devils_fork1=0;
double devils_fork2=0;
double devils_fork3=0;
double devils_fork4=0;
double devils_fork5=0;
double devils_fork6=0;
double devils_fork7=0;
double devils_fork8=0;
double devils_fork9=0;
double devils_fork10=0;
double omega0=0;
double omega1=0;
double omega2=0;
double omega3=0;
double omega4=0;
double omega5=0;
double omega6=0;
double omega7=0;
double omega8=0;
double omega9=0;
double omega10=0;
int n;
v=(Math.Pow(depth,0.67)*Math.Pow(slope,0.5))/manning;
/*** using Meyer Peter & Muller */
/*
if(t>tcrit5)amt5=(muller*pow((t-tcrit5),1.5));
if(t>tcrit4)amt4=(muller*pow((t-tcrit4),1.5));
if(t>tcrit3)amt3=(muller*pow((t-tcrit3),1.5));
if(t>tcrit2)amt2=(muller*pow((t-tcrit2),1.5));
if(t>tcrit1)amt1=(muller*pow((t-tcrit1),1.5));
*/
/*** Using bagnold 1980 **************/
/* assuming density of sed = 2250 & water 1000 */
/* this version gives weight, so divide by density 2250 to give volume */
/*
w=t*v;
wo1=wo_constant*pow(d1,1.5)*log((12*depth/d1));
wo2=wo_constant*pow(d2,1.5)*log((12*depth/d2));
wo3=wo_constant*pow(d3,1.5)*log((12*depth/d3));
wo4=wo_constant*pow(d4,1.5)*log((12*depth/d4));
wo5=wo_constant*pow(d5,1.5)*log((12*depth/d5));
if(w>wo1)amt1=(1.8*0.5*pow(((w-wo1)/Wr),1.5)*pow((depth/Yr),-0.6667)*pow((d1/Dr),-0.5))/2250;
if(w>wo2)amt2=(1.8*0.5*pow(((w-wo2)/Wr),1.5)*pow((depth/Yr),-0.6667)*pow((d2/Dr),-0.5))/2250;
if(w>wo3)amt3=(1.8*0.5*pow(((w-wo3)/Wr),1.5)*pow((depth/Yr),-0.6667)*pow((d3/Dr),-0.5))/2250;
if(w>wo4)amt4=(1.8*0.5*pow(((w-wo4)/Wr),1.5)*pow((depth/Yr),-0.6667)*pow((d4/Dr),-0.5))/2250;
if(w>wo5)amt5=(1.8*0.5*pow(((w-wo5)/Wr),1.5)*pow((depth/Yr),-0.6667)*pow((d5/Dr),-0.5))/2250;
*/
/********* using einstein brown 1950 *********/
/* assuming depth = R */
/* all taken from steves fluid book */
devils_fork0=((2250-1000)*d0)/(1000*depth*slope);
devils_fork1=((2250-1000)*d1)/(1000*depth*slope);
devils_fork2=((2250-1000)*d2)/(1000*depth*slope);
devils_fork3=((2250-1000)*d3)/(1000*depth*slope);
devils_fork4=((2250-1000)*d4)/(1000*depth*slope);
devils_fork5=((2250-1000)*d5)/(1000*depth*slope);
devils_fork6=((2250-1000)*d6)/(1000*depth*slope);
devils_fork7=((2250-1000)*d7)/(1000*depth*slope);
devils_fork8=((2250-1000)*d8)/(1000*depth*slope);
devils_fork9=((2250-1000)*d9)/(1000*depth*slope);
devils_fork10=((2250-1000)*d10)/(1000*depth*slope);
omega0=40*Math.Pow((1/devils_fork0),3);
omega1=40*Math.Pow((1/devils_fork1),3);
omega2=40*Math.Pow((1/devils_fork2),3);
omega3=40*Math.Pow((1/devils_fork3),3);
omega4=40*Math.Pow((1/devils_fork4),3);
omega5=40*Math.Pow((1/devils_fork5),3);
omega6=40*Math.Pow((1/devils_fork6),3);
omega7=40*Math.Pow((1/devils_fork7),3);
omega8=40*Math.Pow((1/devils_fork8),3);
omega9=40*Math.Pow((1/devils_fork9),3);
omega10=40*Math.Pow((1/devils_fork10),3);
amt0=omega0/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d0,3)));
amt1=omega1/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d1,3)));
amt2=omega2/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d2,3)));
amt3=omega3/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d3,3)));
amt4=omega4/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d4,3)));
amt5=omega5/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d5,3)));
amt6=omega6/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d6,3)));
amt7=omega7/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d7,3)));
amt8=omega8/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d8,3)));
amt9=omega9/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d9,3)));
amt10=omega10/Math.Sqrt(1000/((2250-1000)*9.8*Math.Pow(d10,3)));
dist[p,0]=amt0*time_factor;
dist[p,1]=amt1*time_factor;
dist[p,2]=amt2*time_factor;
dist[p,3]=amt3*time_factor;
dist[p,4]=amt4*time_factor;
dist[p,5]=amt5*time_factor;
dist[p,6]=amt6*time_factor;
dist[p,7]=amt7*time_factor;
dist[p,8]=amt8*time_factor;
dist[p,9]=amt9*time_factor;
dist[p,10]=0; /*amt10*time_factor;*/
} // erode2
void erode3(int fract, int grid_val, int x,int y)
{
int n,temp_centre;
double tempb=0;
double tempamt=0;
double total=0;
double total2=0;
if(index[x,y]==-9999)addGS(x,y);
temp_centre=index[x,y];
for(n=1;n<=8;n++)
{
total+=dist[n,fract];
}
/******* lines like the next one, are assential to ensure that it adds new eroded sqaures to the list. **/
if(grain_tot(temp_centre,fract)>0.0001)
{
if(index[x,y]==-9999)addGS(x,y);
if(total>=grain_tot(temp_centre,fract))
{
total2=0;
for(n=1;n<=8;n++)
{
dist[n,fract]=dist[n,fract]*(grain_tot(temp_centre,fract)/total)*0.99999;
total2+=dist[n,fract];
}
}
// if(grain[index[x,y],0,0]>0)
// {
// if(grain[index[x,y],0,0]>active)grain[index[x,y],0,0]=active;
// total2=0;
// for(n=1;n<=8;n++)
// {
// dist[n,fract]=dist[n,fract]*(1-(grain[index[x,y],0,0]/active))*0.99999;
// total2+=dist[n,fract];
// }
// }
if(dist[1,fract]>0.0000)
{
if(index[x-1,y-1]==-9999)addGS(x-1,y-1);
erode4(x,y,temp_centre,fract,dist[1,fract],index[x-1,y-1]);
/* if(grain[temp_centre,fract]+temp[temp_centre,fract]<0){
printf("one %f %f %d %d\n",grain[temp_centre,fract],temp[temp_centre,fract],x,y);
temp[index[x-1,y-1],fract]-=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
temp[temp_centre,fract]+=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
}*/
}
if(dist[2,fract]>0.0000)
{
if(index[x,y-1]==-9999)addGS(x,y-1);
erode4(x,y,temp_centre,fract,dist[2,fract],index[x,y-1]);
/* if(grain[temp_centre,fract]+temp[temp_centre,fract]<0){
printf("two %f %f %d %d\n",grain[temp_centre,fract],temp[temp_centre,fract],x,y);
temp[index[x,y-1],fract]-=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
temp[temp_centre,fract]+=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
}*/
}
if(dist[3,fract]>0.0000)
{
if(index[x+1,y-1]==-9999)addGS(x+1,y-1);
erode4(x,y,temp_centre,fract,dist[3,fract],index[x+1,y-1]);
/* if(grain[temp_centre,fract]+temp[temp_centre,fract]<0){
printf("three %f %f %d %d\n",grain[temp_centre,fract],temp[temp_centre,fract],x,y);
temp[index[x+1,y-1],fract]-=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
temp[temp_centre,fract]+=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
}*/
}
if(dist[4,fract]>0.0000)
{
if(index[x+1,y]==-9999)addGS(x+1,y);
erode4(x,y,temp_centre,fract,dist[4,fract],index[x+1,y]);
/* if(grain[temp_centre,fract]+temp[temp_centre,fract]<0){
printf("four %f %f %d %d\n",grain[temp_centre,fract],temp[temp_centre,fract],x,y);
temp[index[x+1,y],fract]-=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
temp[temp_centre,fract]+=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
}*/
}
if(dist[5,fract]>0.0000)
{
if(index[x+1,y+1]==-9999)addGS(x+1,y+1);
erode4(x,y,temp_centre,fract,dist[5,fract],index[x+1,y+1]);
/* if(grain[temp_centre,fract]+temp[temp_centre,fract]<0){
printf("five %f %f %d %d\n",grain[temp_centre,fract],temp[temp_centre,fract],x,y);
temp[index[x+1,y+1],fract]-=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
temp[temp_centre,fract]+=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
}*/
}
if(dist[6,fract]>0.0000)
{
if(index[x,y+1]==-9999)addGS(x,y+1);
erode4(x,y,temp_centre,fract,dist[6,fract],index[x,y+1]);
/* if(grain[temp_centre,fract]+temp[temp_centre,fract]<0){
printf("six %f %f %d %d\n",grain[temp_centre,fract],temp[temp_centre,fract],x,y);
temp[index[x,y+1],fract]-=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
temp[temp_centre,fract]+=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
}*/
}
if(dist[7,fract]>0.0000)
{
if(index[x-1,y+1]==-9999)addGS(x-1,y+1);
erode4(x,y,temp_centre,fract,dist[7,fract],index[x-1,y+1]);
/*if(grain[temp_centre,fract]+temp[temp_centre,fract]<0){
printf("seven %f %f %d %d\n",grain[temp_centre,fract],temp[temp_centre,fract],x,y);
temp[index[x-1,y+1],fract]-=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
temp[temp_centre,fract]+=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
}*/
}
if(dist[8,fract]>0.0000)
{
if(index[x-1,y]==-9999)addGS(x-1,y);
erode4(x,y,temp_centre,fract,dist[8,fract],index[x-1,y]);
/*if(grain[temp_centre,fract]+temp[temp_centre,fract]<0){
printf("eight %f %f %d %d\n",grain[temp_centre,fract],temp[temp_centre,fract],x,y);
temp[index[x-1,y],fract]-=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
temp[temp_centre,fract]+=fabs(grain[temp_centre,fract]+temp[temp_centre,fract]);
}*/
}
}
} // erode3
void erode4(int x,int y,int cent_from,int fract,double amount,int cent_to)
{
int p;
double total,sub;
total = 0.0;
for (p=0; p<=(TRACERS-1); p++)
{
total += grain[cent_from,fract,p];
}
if (total > 0.0)
{
if (isSuspended[fract])
{
for (p=0; p<=(TRACERS-1); p++)
{
sub = amount*(grain[cent_from,fract,p]/total)/* *0.999999 */;
temp[cent_from,fract,p] -= sub;
sub = sub * DX *DX;
tempsusp[x,y,fract,p] += sub;
tempsusptot[x,y] += sub;
}
}
else
{
for (p=0; p<=(TRACERS-1); p++)
{
sub = amount * (grain[cent_from,fract,p]/total)/* *0.999999 */;
temp[cent_from,fract,p] -= sub;
temp[cent_to,fract,p] += sub;
}
}
}
}
void slide(int scan)
{
double diff,main_crit_ht, crit_ht, wet_crit_ht;
double slide_tot=0;
int tot,n, x;
main_crit_ht=Math.Tan((failureangle*(3.141592654/180)))*DX;
crit_ht=main_crit_ht;
wet_crit_ht=crit_ht/2;
/* printf(" Landslide module 1!!! \n");*/
for (scan=1;scan1;n--)
{
if(elev[n,scan]>0&&elev[n-1,scan]>0)
{
if(elev[n,scan]<=(bedrock[n,scan]+active))
crit_ht=10*DX;
else
crit_ht=main_crit_ht;
if((elev[n,scan]-elev[n-1,scan])>crit_ht)
{
diff=(elev[n,scan]-elev[n-1,scan])-crit_ht;
if((elev[n,scan]-diff)<(bedrock[n,scan]+active))diff=(elev[n,scan]-(bedrock[n,scan]+active));
slide_tot=slide_tot+diff;
elev[n,scan]=elev[n,scan]-diff;
elev[n-1,scan]=elev[n-1,scan]+diff;
if(index[n,scan]!=-9999||index[n-1,scan]!=-9999)slide_GS(n,scan,diff,n-1,scan);
tot++;
}
}
}
for(n=2;n0&&elev[n-1,scan]>0)
{
if(elev[n-1,scan]<=(bedrock[n-1,scan]+active))
crit_ht=10*DX;
else
crit_ht=main_crit_ht;
if((elev[n-1,scan]-elev[n,scan])>crit_ht)
{
diff=(elev[n-1,scan]-elev[n,scan])-crit_ht;
if((elev[n-1,scan]-diff)<(bedrock[n-1,scan]+active))diff=(elev[n-1,scan]-(bedrock[n-1,scan]+active));
slide_tot=slide_tot+diff;
elev[n-1,scan]=elev[n-1,scan]-diff;
elev[n,scan]=elev[n,scan]+diff;
if(index[n,scan]!=-9999||index[n-1,scan]!=-9999)slide_GS(n-1,scan,diff,n,scan);
tot++;
}
}
}
x++;
}while(tot>2&&x<200);
}
for (n=1;n<=xmax;n++)
{
x=0;
do
{
tot=0;
for(scan=ymax-1;scan>1;scan--)
{
if(elev[n,scan]>0&&elev[n,scan-1]>0)
{
if(elev[n,scan]<=(bedrock[n,scan]+active))
crit_ht=10*DX;
else
crit_ht=main_crit_ht;
if((elev[n,scan]-elev[n,scan-1])>crit_ht)
{
diff=(elev[n,scan]-elev[n,scan-1])-crit_ht;
if((elev[n,scan]-diff)<(bedrock[n,scan]+active))diff=(elev[n,scan]-(bedrock[n,scan]+active));
slide_tot=slide_tot+diff;
elev[n,scan]=elev[n,scan]-diff;
elev[n,scan-1]=elev[n,scan-1]+diff;
if(index[n,scan-1]!=-9999||index[n,scan]!=-9999)slide_GS(n,scan,diff,n,scan-1);
tot++;
}
}
}
for(scan=2;scan0&&elev[n,scan-1]>0)
{
if(bedrock[n,scan-1]<=(bedrock[n,scan-1]+active))
crit_ht=10*DX;
else
crit_ht=main_crit_ht;
if((elev[n,scan-1]-elev[n,scan])>crit_ht)
{
diff=(elev[n,scan-1]-elev[n,scan])-crit_ht;
if((elev[n,scan-1]-diff)<(bedrock[n,scan-1]+active))diff=(elev[n,scan-1]-(bedrock[n,scan-1]+active));
slide_tot=slide_tot+diff;
elev[n,scan-1]=elev[n,scan-1]-diff;
elev[n,scan]=elev[n,scan]+diff;
if(index[n,scan]!=-9999||index[n,scan-1]!=-9999)slide_GS(n,scan-1,diff,n,scan);
tot++;
}
}
}
x++;
}while(tot>2&&x<200);
}
}
void slide_3()
{
int x,y,inc;
double wet_factor;
double factor=Math.Tan((failureangle*(3.141592654/180)))*DX;
double diff=0;
for(y=2;y0)
{
x=down_scan[y,inc];
if(x==xmax)x=xmax-1;
if(x==1)x=2;
inc++;
water_depth[x,y]=0;
/** check to see if under water **/
wet_factor=factor;
if(water_depth[x,y]>0.01)wet_factor=factor/2;
if(elev[x,y]<=(bedrock[x,y]+active))wet_factor=10*DX;
/** chexk landslides in channel slowly */
if(((elev[x,y]-elev[x+1,y+1])/1.41)>wet_factor&&elev[x+1,y+1]>0&&water_depth[x+1,y+1]!=-9999)
{
diff=((elev[x,y]-elev[x+1,y+1])/1.41)-wet_factor;
if((elev[x,y]-diff)<(bedrock[x,y]+active))diff=(elev[x,y]-(bedrock[x,y]+active));
elev[x,y]-=diff;
elev[x+1,y+1]+=diff;
slide_GS(x,y,diff,x+1,y+1);
}
if((elev[x,y]-elev[x,y+1])>wet_factor&&elev[x,y+1]>0&&water_depth[x,y+1]!=-9999)
{
diff=(elev[x,y]-elev[x,y+1])-wet_factor;
if((elev[x,y]-diff)<(bedrock[x,y]+active))diff=(elev[x,y]-(bedrock[x,y]+active));
elev[x,y]-=diff;
elev[x,y+1]+=diff;
slide_GS(x,y,diff,x,y+1);
}
if(((elev[x,y]-elev[x-1,y+1])/1.41)>wet_factor&&elev[x-1,y+1]>0&&water_depth[x-1,y+1]!=-9999)
{
diff=((elev[x,y]-elev[x-1,y+1])/1.41)-wet_factor;
if((elev[x,y]-diff)<(bedrock[x,y]+active))diff=(elev[x,y]-(bedrock[x,y]+active));
elev[x,y]-=diff;
elev[x-1,y+1]+=diff;
slide_GS(x,y,diff,x-1,y+1);
}
if((elev[x,y]-elev[x-1,y])>wet_factor&&elev[x-1,y]>0&&water_depth[x-1,y]!=-9999)
{
diff=(elev[x,y]-elev[x-1,y])-wet_factor;
if((elev[x,y]-diff)<(bedrock[x,y]+active))diff=(elev[x,y]-(bedrock[x,y]+active));
elev[x,y]-=diff;
elev[x-1,y]+=diff;
slide_GS(x,y,diff,x-1,y);
}
if(((elev[x,y]-elev[x-1,y-1])/1.41)>wet_factor&&elev[x-1,y-1]>0&&water_depth[x-1,y-1]!=-9999)
{
diff=((elev[x,y]-elev[x-1,y-1])/1.41)-wet_factor;
if((elev[x,y]-diff)<(bedrock[x,y]+active))diff=(elev[x,y]-(bedrock[x,y]+active));
elev[x,y]-=diff;
elev[x-1,y-1]+=diff;
slide_GS(x,y,diff,x-1,y-1);
}
if((elev[x,y]-elev[x,y-1])>wet_factor&&elev[x,y-1]>0&&water_depth[x,y-1]!=-9999)
{
diff=(elev[x,y]-elev[x,y-1])-wet_factor;
if((elev[x,y]-diff)<(bedrock[x,y]+active))diff=(elev[x,y]-(bedrock[x,y]+active));
elev[x,y]-=diff;
elev[x,y-1]+=diff;
slide_GS(x,y,diff,x,y-1);
}
if(((elev[x,y]-elev[x+1,y-1])/1.41)>wet_factor&&elev[x+1,y-1]>0&&water_depth[x+1,y-1]!=-9999)
{
diff=((elev[x,y]-elev[x+1,y-1])/1.41)-wet_factor;
if((elev[x,y]-diff)<(bedrock[x,y]+active))diff=(elev[x,y]-(bedrock[x,y]+active));
elev[x,y]-=diff;
elev[x+1,y-1]+=diff;
slide_GS(x,y,diff,x+1,y-1);
}
/* if(dist[n,fract]<0.000001)dist[n,fract]=0;*/ if((elev[x,y]-elev[x+1,y])>wet_factor&&elev[x+1,y]>0&&water_depth[x+1,y]!=-9999)
{
diff=(elev[x,y]-elev[x+1,y])-wet_factor;
if((elev[x,y]-diff)<(bedrock[x,y]+active))diff=(elev[x,y]-(bedrock[x,y]+active));
elev[x,y]-=diff;
elev[x+1,y]+=diff;
slide_GS(x,y,diff,x+1,y);
}
}
}
}
void slide_GS(int x,int y,double amount,int x2,int y2)
{
/** Ok, heres how it works, x and y are ones material moved from,
x2 and y2 are ones material moved to...
amd amount is the amount shifted. */
int n,z;
double total=0;
// do only for cells where both have grainsize..
if(index[x,y]!=-9999&&index[x2,y2]!=-9999)
{
z=0;
if(amount>active)
{
grain[index[x2,y2],1,z]+=(amount-active)*d1prop;
grain[index[x2,y2],2,z]+=(amount-active)*d2prop;
grain[index[x2,y2],3,z]+=(amount-active)*d3prop;
grain[index[x2,y2],4,z]+=(amount-active)*d4prop;
grain[index[x2,y2],5,z]+=(amount-active)*d5prop;
grain[index[x2,y2],6,z]+=(amount-active)*d6prop;
grain[index[x2,y2],7,z]+=(amount-active)*d7prop;
grain[index[x2,y2],8,z]+=(amount-active)*d8prop;
grain[index[x2,y2],9,z]+=(amount-active)*d9prop;
amount=active;
}
for(n=1;n<=(G_MAX-1);n++)
{
if(grain_tot(index[x,y],n)>0.000)total+=grain_tot(index[x,y],n);
}
for(n=1;n<=(G_MAX-1);n++)
{
for(z=0;z<=(TRACERS-1);z++)
{
if(total>0)
{
grain[index[x2,y2],n,z]+=amount*(grain[index[x,y],n,z]/total);
if(grain[index[x,y],n,z]>0.0001)grain[index[x,y],n,z]-=amount*(grain[index[x,y],n,z]/total);
if(grain[index[x,y],n,z]<0)grain[index[x,y],n,z]=0;
}
}
}
/* then to set active layer to correct depth before erosion, */
sort_active(x, y);
sort_active(x2, y2);
}
//now do for cells where only recieving cells have grainsize
// just adds amount to reviving cells of normal..
if (index[x, y] == -9999 && index[x2, y2] != -9999)
{
z = 0;
grain[index[x2, y2], 1, z] += (amount) * d1prop;
grain[index[x2, y2], 2, z] += (amount) * d2prop;
grain[index[x2, y2], 3, z] += (amount) * d3prop;
grain[index[x2, y2], 4, z] += (amount) * d4prop;
grain[index[x2, y2], 5, z] += (amount) * d5prop;
grain[index[x2, y2], 6, z] += (amount) * d6prop;
grain[index[x2, y2], 7, z] += (amount) * d7prop;
grain[index[x2, y2], 8, z] += (amount) * d8prop;
grain[index[x2, y2], 9, z] += (amount) * d9prop;
/* then to set active layer to correct depth before erosion, */
sort_active(x2, y2);
}
// now for cells whre dontaing cell has grainsize
if (index[x, y] != -9999 && index[x2, y2] == -9999)
{
z = 0;
addGS(x2, y2); // add grainsize array for recieving cell..
if (amount > active)
{
grain[index[x2, y2], 1, z] += (amount - active) * d1prop;
grain[index[x2, y2], 2, z] += (amount - active) * d2prop;
grain[index[x2, y2], 3, z] += (amount - active) * d3prop;
grain[index[x2, y2], 4, z] += (amount - active) * d4prop;
grain[index[x2, y2], 5, z] += (amount - active) * d5prop;
grain[index[x2, y2], 6, z] += (amount - active) * d6prop;
grain[index[x2, y2], 7, z] += (amount - active) * d7prop;
grain[index[x2, y2], 8, z] += (amount - active) * d8prop;
grain[index[x2, y2], 9, z] += (amount - active) * d9prop;
amount = active;
}
for (n = 1; n <= (G_MAX - 1); n++)
{
if (grain_tot(index[x, y], n) > 0.000) total += grain_tot(index[x, y], n);
}
for (n = 1; n <= (G_MAX - 1); n++)
{
for (z = 0; z <= (TRACERS - 1); z++)
{
if (total > 0)
{
grain[index[x2, y2], n, z] += amount * (grain[index[x, y], n, z] / total);
if (grain[index[x, y], n, z] > 0.0001) grain[index[x, y], n, z] -= amount * (grain[index[x, y], n, z] / total);
if (grain[index[x, y], n, z] < 0) grain[index[x, y], n, z] = 0;
}
}
}
/* then to set active layer to correct depth before erosion, */
sort_active(x, y);
sort_active(x2, y2);
}
}
void lateral2()
{
int x, y, n, inc, dir;
double[,] edge_temp, edge_temp2, meanwselev;
int[,] upscale, upscale_edge;
edge_temp = new Double[xmax + 1, ymax + 1];
edge_temp2 = new Double[xmax + 1, ymax + 1];
meanwselev = new Double[xmax + 1, ymax + 1];
upscale = new int[(xmax + 1) * 2, (ymax + 1) * 2];
upscale_edge = new int[(xmax + 1) * 2, (ymax + 1) * 2];
double mft = 0.0000001;// MIN_Q;// max_flow threshold
double temp;
// double[,]tempgs;
// tempgs = new double[xmax*ymax*8,5];
// First remove spurious wet cells.
for (x = 1; x <= (xmax); x++)
{
inc = 1;
while (cross_scan[x, inc] > 0)
{
y = cross_scan[x, inc];
inc++;
meanwselev[x, y] = water_depth[x, y] + elev[x, y];
if (max_flow[x, y, 0] > mft)
{
int tempcounter = 0;
for (dir = 1; dir <= 8; dir++)
{
int x2, y2;
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if (max_flow[x2, y2, 0] < mft) tempcounter++;
}
if (tempcounter > 6) water_depth[x, y] = 0;
}
}
}
// first determine which cells are at the edge of the channel
for (y = 2; y < ymax; y++)
{
for (x = 2; x < xmax; x++)
{
edge[x, y] = -9999;
if (max_flow[x, y, 0] < mft)
{
if (max_flow[x, y - 1, 0] > mft ||
max_flow[x - 1, y, 0] > mft ||
max_flow[x + 1, y, 0] > mft ||
max_flow[x, y + 1, 0] > mft)
{
edge[x, y] = 0;
edge2[x, y] = 0;
}
}
if (max_flow[x, y, 0] < mft)
{
if (max_flow[x, y - 1, 0] > mft &&
max_flow[x - 1, y, 0] > mft &&
max_flow[x + 1, y, 0] > mft &&
max_flow[x, y + 1, 0] > mft)
{
edge[x, y] = -9999;
edge2[x, y] = -9999;
}
}
}
}
// new upscaling code
// first determine wet and dry cells on the new grid
for (x = 1; x <= xmax; x++)
{
for (y = 1; y <= ymax; y++)
{
if (max_flow[x, y, 0] < mft)
{
upscale[(x * 2), (y * 2)] = 0; // if dry
upscale[(x * 2), (y * 2) - 1] = 0;
upscale[(x * 2) - 1, (y * 2)] = 0;
upscale[(x * 2) - 1, (y * 2) - 1] = 0;
}
if (max_flow[x, y, 0] >= mft)
{
upscale[(x * 2), (y * 2)] = 1; // if wet
upscale[(x * 2), (y * 2) - 1] = 1;
upscale[(x * 2) - 1, (y * 2)] = 1;
upscale[(x * 2) - 1, (y * 2) - 1] = 1;
}
}
}
// now determine edge cells on the new grid..
for (y = 2; y < ymax * 2; y++)
{
for (x = 2; x < xmax * 2; x++)
{
upscale_edge[x, y] = 0;
if (upscale[x, y] == 0)
{
if (upscale[x, y - 1] == 1 ||
upscale[x - 1, y] == 1 ||
upscale[x + 1, y] == 1 ||
upscale[x, y + 1] == 1)
{
upscale[x, y] = 2;
}
}
}
}
// now tall up inside and outside on upscaled grid
for (y = 2; y < ymax * 2; y++)
{
for (x = 2; x < xmax * 2; x++)
{
if (upscale[x, y] == 2)
{
int wetcells = 0;
int drycells = 0;
int water = 0;
int edge_cell_counter = 1;
// sum up dry cells and edge cells -
// now manhattan neighbors
for (dir = 1; dir <= 7; dir += 2)
{
int x2, y2;
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if (upscale[x2, y2] == 1) wetcells += 1;
if (upscale[x2, y2] == 0) drycells += 1;
if (upscale[x2, y2] == 2) edge_cell_counter += 1;
}
if (edge_cell_counter > 3) drycells += edge_cell_counter - 3;
//
water = wetcells - drycells;
//if (drycells >= 3) water = 0;
//if (wetcells >= 3) water = 0;
upscale_edge[x, y] = water;
// remove edge effects
if (x < 6 || x > ((xmax * 2) - 6)) upscale_edge[x, y] = 0;
}
}
}
// now update normal edge array..
for (x = 1; x <= xmax; x++)
{
for (y = 1; y <= ymax; y++)
{
if (edge[x, y] == 0)
{
edge[x, y] = (double)(upscale_edge[(x * 2), (y * 2)] +
upscale_edge[(x * 2), (y * 2) - 1] +
upscale_edge[(x * 2) - 1, (y * 2)] +
upscale_edge[(x * 2) - 1, (y * 2) - 1]);
if (edge[x, y] > 2) edge[x, y] = 2; // important line to stop too great inside bends...
if (edge[x, y] > 0) edge[x, y] *= 1.1;
//edge[31, 32] = 5;
}
}
}
//then apply a smoothing filter over the top of this. here its done three times -
for (n = 1; n <= 60; n++)
{
for (y = 2; y < ymax; y++)
{
inc = 1;
while (down_scan[y, inc] > 0)
{
x = down_scan[y, inc];
edge_temp[x, y] = 0;
if (x == 1) x++;
if (x == xmax) x--;
inc++;
if (edge[x, y] > -9999)
{
double mean = 0;
double num = 0;
double water_flag = 0;
// add in cell itself..
mean += edge[x, y];
num++;
for (dir = 1; dir <= 8; dir++)
{
int x2, y2;
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if (max_flow[x2, y2, 0] > mft) water_flag++;
if (n <= 50 && edge[x2, y2] > -9999)
{
//now to mean manhattan neighbours - only if they share a wet diagonal neighbour
if ((Math.Abs(deltaX[dir]) + Math.Abs(deltaY[dir])) != 2)
{
if (deltaX[dir] == 1 && deltaY[dir] == 0 &&
(max_flow[x + 1, y - 1, 0] > mft ||
max_flow[x + 1, y + 1, 0] > mft))
{
mean += (edge[x + deltaX[dir], y + deltaY[dir]]);
num++;
}
if (deltaX[dir] == 0 && deltaY[dir] == 1 &&
(max_flow[x + 1, y + 1, 0] > mft ||
max_flow[x - 1, y + 1, 0] > mft))
{
mean += (edge[x + deltaX[dir], y + deltaY[dir]]);
num++;
}
if (deltaX[dir] == -1 && deltaY[dir] == 0 &&
(max_flow[x - 1, y - 1, 0] > mft ||
max_flow[x - 1, y + 1, 0] > mft))
{
mean += (edge[x + deltaX[dir], y + deltaY[dir]]);
num++;
}
if (deltaX[dir] == 0 && deltaY[dir] == -1 &&
(max_flow[x - 1, y - 1, 0] > mft ||
max_flow[x + 1, y - 1, 0] > mft))
{
mean += (edge[x + deltaX[dir], y + deltaY[dir]]);
num++;
}
// mean+=(edge[x2,y2]);
// num++;
}
//now non manahttan neighbours, with concected by a dry cell checked..
else
{
if (deltaX[dir] == -1 && deltaY[dir] == -1 &&
(max_flow[x, y - 1, 0] < mft ||
max_flow[x - 1, y, 0] < mft))
{
mean += (edge[x + deltaX[dir], y + deltaY[dir]]);
num++;
}
if (deltaX[dir] == 1 && deltaY[dir] == -1 &&
(max_flow[x, y - 1, 0] < mft ||
max_flow[x + 1, y, 0] < mft))
{
mean += (edge[x + deltaX[dir], y + deltaY[dir]]);
num++;
}
if (deltaX[dir] == 1 && deltaY[dir] == 1 &&
(max_flow[x + 1, y, 0] < mft ||
max_flow[x, y + 1, 0] < mft))
{
mean += (edge[x + deltaX[dir], y + deltaY[dir]]);
num++;
}
if (deltaX[dir] == -1 && deltaY[dir] == 1 &&
(max_flow[x, y + 1, 0] < mft ||
max_flow[x - 1, y, 0] < mft))
{
mean += (edge[x + deltaX[dir], y + deltaY[dir]]);
num++;
}
}
}
// do this part for the second part of the smoothing.. does the downslope smoothing part...
if (n > 50 && edge[x2, y2] > -9999)
{
////now to mean manhattan neighbours - only if they share a wet diagonal neighbour
//if((Math.Abs(deltaX[dir])+Math.Abs(deltaY[dir]))!=2)
//{
// if(deltaX[dir]==1&&deltaY[dir]==0&&
// (Tau[x+1,y-1]>mft||
// Tau[x+1,y+1]>mft)&&
// xplus>0)
// {
// mean+=(edge[x+deltaX[dir],y+deltaY[dir]]);
// num++;
// }
// if(deltaX[dir]==0&&deltaY[dir]==1&&
// (Tau[x+1,y+1]>mft||
// Tau[x-1,y+1]>mft)&&
// yminus>0)
// {
// mean+=(edge[x+deltaX[dir],y+deltaY[dir]]);
// num++;
// }
// if(deltaX[dir]==-1&&deltaY[dir]==0&&
// (Tau[x-1,y-1]>mft||
// Tau[x-1,y+1]>mft)&&
// xminus>0)
// {
// mean+=(edge[x+deltaX[dir],y+deltaY[dir]]);
// num++;
// }
// if(deltaX[dir]==0&&deltaY[dir]==-1&&
// (Tau[x-1,y-1]>mft||
// Tau[x+1,y-1]>mft)&&
// yplus>0)
// {
// mean+=(edge[x+deltaX[dir],y+deltaY[dir]]);
// num++;
// }
//}
// //now non manahttan neighbours, with concected by a dry cell checked..
//else
//{
// if(deltaX[dir]==-1&&deltaY[dir]==-1&&
// (Tau[x,y-1]0||yplus>0))
// {
// mean+=(edge[x+deltaX[dir],y+deltaY[dir]]);
// num++;
// }
// if(deltaX[dir]==1&&deltaY[dir]==-1&&
// (Tau[x,y-1]0||yplus>0))
// {
// mean+=(edge[x+deltaX[dir],y+deltaY[dir]]);
// num++;
// }
// if(deltaX[dir]==1&&deltaY[dir]==1&&
// (Tau[x+1,y]0||yminus>0))
// {
// mean+=(edge[x+deltaX[dir],y+deltaY[dir]]);
// num++;
// }
// if(deltaX[dir]==-1&&deltaY[dir]==1&&
// (Tau[x,y+1]0||yminus>0))
// {
// mean+=(edge[x+deltaX[dir],y+deltaY[dir]]);
// num++;
// }
//}
}
}
edge_temp[x, y] = mean / num;
// removes too many cells - islands etc..
//if(num>5&&edge[x,y]>0)edge_temp[x,y]=0;
//if(num+water_flag>7&&edge[x,y]>0)edge_temp[x,y]=0;
// remove edge effects
if (x < 4 || x > (xmax - 2)) edge_temp[x, y] = 0;
}
}
}
for (y = 2; y < ymax; y++)
{
inc = 1;
while (down_scan[y, inc] > 0)
{
x = down_scan[y, inc];
if (x == 1) x++;
if (x == xmax) x--;
inc++;
if (edge[x, y] > -9999)
{
edge[x, y] = edge_temp[x, y];
//if(edge[x,y]<-1)edge[x,y]=-1;
//if(edge[x,y]>1)edge[x,y]=1;
}
}
}
}
// trial line to remove too high inside bends,,
for (x = 1; x <= xmax; x++)
{
for (y = 1; y <= ymax; y++)
{
//if (edge[x, y] > 0) edge[x, y] *= 2;
if (edge[x, y] > -9999) edge[x, y] *= 0.5;
if (edge[x, y] > -9999 && edge[x, y] > 0.25) edge[x, y] = 0.25;
if (edge[x, y] > -9999 && edge[x, y] < -0.1) edge[x, y] = -0.1;
width[x, y] = 0;
if (edge[x, y] > -9999) edge2[x, y] = Math.Abs(edge[x, y]);
if (max_flow[x, y, 0] >= mft) calc_width(x, y);
//if(water_depth[x,y]>0.1)calc_width(x,y);
}
}
//// now smooth actross the channel..
double tempdiff = 0;
do
{
for (y = 2; y < ymax; y++)
{
inc = 1;
while (down_scan[y, inc] > 0)
{
x = down_scan[y, inc];
edge_temp[x, y] = 0;
edge_temp2[x, y] = 0;
if (x == 1) x++;
if (x == xmax) x--;
inc++;
if (max_flow[x, y, 0] > mft && edge[x, y] == -9999) edge[x, y] = 0;
if (edge[x, y] > -9999 && max_flow[x, y, 0] > mft)
{
double mean = 0, mean2 = 0;
int num = 0, num2 = 0;
mean2 += edge2[x, y]; num2++;
for (dir = 1; dir <= 8; dir++)
{
int x2, y2;
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
if (max_flow[x2, y2, 0] > mft && edge[x2, y2] == -9999) edge[x2, y2] = 0;
//if(edge[x2,y2]>-9999&&(water_depth[x,y]+elev[x,y])<(water_depth[x2,y2]+elev[x2,y2]))
if (edge[x2, y2] > -9999)
{
//if(Math.IEEERemainder(dir,2)!=0)mean+=(edge[x2,y2]); profiling found these lines were computationally very intensive!
//if(Math.IEEERemainder(dir,2)==0)mean+=(edge[x2,y2]/1.41);
mean += (edge[x2, y2]);
num++;
mean2 += Math.Abs(edge2[x2, y2]);
//if(Math.IEEERemainder(dir,2)==0)mean2+=Math.Abs(edge2[x2,y2]/1.41);
num2++;
}
}
edge_temp[x, y] = mean / num;
edge_temp2[x, y] = mean2 / num2;
}
}
}
tempdiff = 0;
for (y = 2; y < ymax; y++)
{
inc = 1;
while (down_scan[y, inc] > 0)
{
x = down_scan[y, inc];
if (x == 1) x++;
if (x == xmax) x--;
inc++;
if (edge[x, y] > -9999 && max_flow[x, y, 0] > mft)
{
if (Math.Abs(edge[x, y] - edge_temp[x, y]) > tempdiff) tempdiff = Math.Abs(edge[x, y] - edge_temp[x, y]);
edge[x, y] = edge_temp[x, y];
edge2[x, y] = edge_temp2[x, y];
}
}
}
} while (tempdiff > 0.0001); //this makes it loop until the averaging across the stream stabilises
// so that the difference between the old and new values are < 0.0001
for (x = 1; x <= xmax; x++)
{
for (y = 1; y <= ymax; y++)
{
tempcreep[x, y] = 0;
if (edge[x, y] > -9999) edge[x, y] = 0 - edge[x, y];
if (edge[x, y] > -9999 && edge[x, y] > 0.25) edge[x, y] = 0.25;
if (edge[x, y] > -9999 && edge[x, y] < -0.25) edge[x, y] = -0.25;
if (edge[x, y] > -9999 && (x < 3 || x > (xmax - 3))) edge[x, y] = 0;
}
}
n = 0;
for (x = 2; x < xmax; x++)
{
for (y = 2; y < ymax; y++)
{
if (edge[x, y] > -9999)
{
for (dir = 1; dir <= 8; dir++)//was 1 to 8 +=2
{
int x2, y2;
x2 = x + deltaX[dir];
y2 = y + deltaY[dir];
temp = 0;
double temp3 = 0;
if (index[x2, y2] != -9999) for (n = 1; n <= G_MAX; n++) temp3 += temp_tot(index[x2, y2], n);
if (temp3 > 0) temp3 = 0;
temp3 = 0 - temp3;
if (edge[x2, y2] > -9999)
{
if (/*edge[x,y]>0
&&edge[x2,y2] mft
&& elev[x, y] > 0
&& elev[x, y] > elev[x2, y2])
{
if (((2.131 * Math.Pow(edge[x, y], -1.0794)) * DX) / (DX * width[x2, y2]) > 4 && ((2.131 * Math.Pow(edge[x, y], -1.0794)) * DX) / (DX * width[x2, y2]) < 500)
{
if (latbox1.Checked == true && Tau[x2, y2] > 5)
{
temp = (2 / (((2.131 * Math.Pow(edge[x, y], -1.0794)) * DX) / (DX * width[x2, y2]))) * Math.Pow((Tau[x2, y2] - 5), 1.5) * 0.1 * time_factor * lateral_constant;
}
if (latbox2.Checked == true) temp = (2 / (((2.131 * Math.Pow(edge[x, y], -1.0794)) * DX) / (DX * width[x2, y2]))) * (max_flow[x2, y2, 0] / (DX * water_depth2[x2, y2])) * time_factor * lateral_constant;
//if (latbox3.Checked == true) temp = (2 / (((2.131 * Math.Pow(edge[x, y], -1.0794)) * DX) / (DX * width[x2, y2]))) * water_depth[x2, y2] * lateral_constant;
}
if (latbox3.Checked == true) temp = time_factor * lateral_constant * temp3;
}
if (temp > 0)// needed to ensure that it doesnt do temp and add gs things if no lat erosion/dep
{
//if(Math.IEEERemainder(dir,2)==0)temp/=2; // line to reduce odd corners
temp = temp / DX; // imporant scaling term, links temp to grid cell size - as temp change here is lateral rate..
//if((Math.Abs(deltaX[dir])+Math.Abs(deltaY[dir]))!=2)temp=temp/2.82;
Console.WriteLine(Convert.ToString(temp));
//if(temp>0.001)temp=0.001;
//if(temp>temp3)temp=temp3; // stops it eroding more than is being removed by main channel
tempcreep[x, y] -= temp;
tempcreep[x2, y2] += temp;// *double.Parse(propremaining.Text);
slide_GS(x, y, temp, x2, y2);
}
}
}
}
}
}
for (x = 1; x <= xmax; x++)
{
for (y = 1; y <= ymax; y++)
{
elev[x, y] += tempcreep[x, y];
flow_dir[x, y, 0] = 0;
flow_dir[x, y, 1] = 0;
for (n = 0; n <= 8; n++)
{
max_flow[x, y, n] = 0;
}
old_water_depth[x, y] = water_depth[x, y];
if (water_depth[x, y] > 0) water_depth[x, y] = 0;
qcounter[x, y] = 0;
if (discharge[x, y] < 0) discharge[x, y] = 0;
lat_vol[x, y] = discharge[x, y];//
left_in[x, y] = 0;
left_out[x, y] = 0;
right_in[x, y] = 0;
right_out[x, y] = 0;
up_in[x, y] = 0;
up_out[x, y] = 0;
down_in[x, y] = 0;
down_out[x, y] = 0;
Tau[x, y] = 0;
//discharge[x,y]*=0.99;
//max_left[x,y]=discharge[x,y];
//discharge[x,y]/=1.002;
//if(discharge[x,y]>0)Console.WriteLine(Convert.ToString(discharge[x,y]));
// this line also reduces part of the remaining Qw - a kind of evaporation
// else you can end up with trapped bodies of water..
// altered by MJ 15/03/05 - parameterized evaporation
if ((k_evap > 0.0) && (discharge[x, y] > 0.0))
{
discharge[x, y] -= time_factor * k_evap * (DX * DX);
if (discharge[x, y] < 0.0) discharge[x, y] = 0.0;
}
}
}
}
void lateral()
{
int x,y,n,inc;
int ml1x=0,ml1y=0, ml1x_rec=0, ml1y_rec=0,
ml2x=0,ml2y=0,
ml3x=0,ml3y=0,
el1x_rec, el1y_rec,
el2x_rec, el2y_rec,
mr1x=0,mr1y=0, mr1x_rec=0, mr1y_rec=0,
mr2x=0,mr2y=0,
mr3x=0,mr3y=0,
er1x_rec, er1y_rec,
er2x_rec, er2y_rec,
hl,ml,el,hr,mr,er;
double tot,amount;
double dz=0;
/* calculate lateral erosion */
/*
*/
for(y=ymax;y>=1;y--)
{
inc=1;
while(down_scan[y,inc]>0)
{
x=down_scan[y,inc];
inc++;
if(water_depth[x,y]>water_depth_erosion_threshold&&flow_dir[x,y,0]!=0&&flow_dir[x,y,1]!=0&&(flow_dir[x,y,0]-flow_dir[x,y,1])!=4&&(flow_dir[x,y,0]-flow_dir[x,y,1])!=-4)
{
/*printf("\n %d %d",x,y);*/
hl=0;ml=0;el=0;hr=0;mr=0;er=0;
/* now do lateral erosion bit
this determines the flow direction in - */
if(flow_dir[x,y,0]==1)
{
ml=3;
ml1x=x; ml1y=y+1;
ml2x=x-1; ml2y=y+1;
ml3x=x-1; ml3y=y;
ml1x_rec=x+1; ml1y_rec=y-1;
el1x_rec=x+1; el1y_rec=y-1;
el2x_rec=x+1; el2y_rec=y;
el=4;
/* no need for easy right or left, as co-ords same as ml!*/
mr=7;
mr1x=x; mr1y=y+1;
mr2x=x+1; mr2y=y+1;
mr3x=x+1; mr3y=y;
mr1x_rec=x-1; mr1y_rec=y-1;
er1x_rec=x-1; er1y_rec=y-1;
er2x_rec=x-1; er2y_rec=y;
er=6;
}
if(flow_dir[x,y,0]==2)
{
ml=4;
ml1x=x-1; ml1y=y+1;
ml2x=x-1; ml2y=y;
ml3x=x-1; ml3y=y-1;
ml1x_rec=x+1; ml1y_rec=y;
el1x_rec=x+1; el1y_rec=y;
el2x_rec=x+1; el2y_rec=y+1;
el=5;
/* no need for easy right or left, as co-ords same as ml!*/
mr=8;
mr1x=x-1; mr1y=y+1;
mr2x=x; mr2y=y+1;
mr3x=x+1; mr3y=y+1;
mr1x_rec=x; mr1y_rec=y-1;
er1x_rec=x; er1y_rec=y-1;
er2x_rec=x-1; er2y_rec=y-1;
er=7;
}
if(flow_dir[x,y,0]==3)
{
ml=5;
ml1x=x-1; ml1y=y;
ml2x=x-1; ml2y=y-1;
ml3x=x; ml3y=y-1;
ml1x_rec=x+1; ml1y_rec=y+1;
el1x_rec=x+1; el1y_rec=y+1;
el2x_rec=x; el2y_rec=y+1;
el=6;
/* no need for easy right or left, as co-ords same as ml!*/
mr=1;
mr1x=x-1; mr1y=y;
mr2x=x-1; mr2y=y+1;
mr3x=x; mr3y=y+1;
mr1x_rec=x+1; mr1y_rec=y-1;
er1x_rec=x+1; er1y_rec=y-1;
er2x_rec=x; er2y_rec=y-1;
er=8;
}
if(flow_dir[x,y,0]==4)
{
ml=6;
ml1x=x-1; ml1y=y-1;
ml2x=x; ml2y=y-1;
ml3x=x+1; ml3y=y-1;
ml1x_rec=x; ml1y_rec=y+1;
el1x_rec=x; el1y_rec=y+1;
el2x_rec=x-1; el2y_rec=y+1;
el=7;
/* no need for easy right or left, as co-ords same as ml!*/
mr=2;
mr1x=x-1; mr1y=y-1;
mr2x=x-1; mr2y=y;
mr3x=x-1; mr3y=y+1;
mr1x_rec=x+1; mr1y_rec=y;
er1x_rec=x+1; er1y_rec=y;
er2x_rec=x+1; er2y_rec=y-1;
er=1;
}
if(flow_dir[x,y,0]==5)
{
ml=7;
ml1x=x; ml1y=y-1;
ml2x=x+1; ml2y=y-1;
ml3x=x+1; ml3y=y;
ml1x_rec=x-1; ml1y_rec=y+1;
el1x_rec=x-1; el1y_rec=y+1;
el2x_rec=x-1; el2y_rec=y;
el=8;
/* no need for easy right or left, as co-ords same as ml!*/
mr=3;
mr1x=x; mr1y=y-1;
mr2x=x-1; mr2y=y-1;
mr3x=x-1; mr3y=y;
mr1x_rec=x+1; mr1y_rec=y+1;
er1x_rec=x+1; er1y_rec=y+1;
er2x_rec=x+1; er2y_rec=y;
er=2;
}
if(flow_dir[x,y,0]==6)
{
ml=8;
ml1x=x+1; ml1y=y-1;
ml2x=x+1; ml2y=y;
ml3x=x+1; ml3y=y+1;
ml1x_rec=x-1; ml1y_rec=y;
el1x_rec=x-1; el1y_rec=y;
el2x_rec=x-1; el2y_rec=y-1;
el=1;
/* no need for easy right or left, as co-ords same as ml!*/
mr=4;
mr1x=x+1; mr1y=y-1;
mr2x=x; mr2y=y-1;
mr3x=x-1; mr3y=y-1;
mr1x_rec=x; mr1y_rec=y+1;
er1x_rec=x; er1y_rec=y+1;
er2x_rec=x+1; er2y_rec=y+1;
er=3;
}
if(flow_dir[x,y,0]==7)
{
ml=1;
ml1x=x+1; ml1y=y;
ml2x=x+1; ml2y=y+1;
ml3x=x; ml3y=y+1;
ml1x_rec=x-1; ml1y_rec=y-1;
el1x_rec=x-1; el1y_rec=y-1;
el2x_rec=x; el2y_rec=y-1;
el=2;
/* no need for easy right or left, as co-ords same as ml!*/
mr=5;
mr1x=x+1; mr1y=y;
mr2x=x+1; mr2y=y-1;
mr3x=x; mr3y=y-1;
mr1x_rec=x-1; mr1y_rec=y+1;
er1x_rec=x-1; er1y_rec=y+1;
er2x_rec=x; er2y_rec=y+1;
er=4;
}
if(flow_dir[x,y,0]==8)
{
ml=2;
ml1x=x+1; ml1y=y+1;
ml2x=x; ml2y=y+1;
ml3x=x-1; ml3y=y+1;
ml1x_rec=x; ml1y_rec=y-1;
el1x_rec=x; el1y_rec=y-1;
el2x_rec=x+1; el2y_rec=y-1;
el=3;
/* no need for easy right or left, as co-ords same as ml!*/
mr=6;
mr1x=x+1; mr1y=y+1;
mr2x=x+1; mr2y=y;
mr3x=x+1; mr3y=y-1;
mr1x_rec=x-1; mr1y_rec=y;
er1x_rec=x-1; er1y_rec=y;
er2x_rec=x-1; er2y_rec=y+1;
er=5;
}
/* then erosion bit-- */
if(flow_dir[x,y,1]==ml)
{
/* do medium left erosion */
if(elev[ml1x,ml1y]>elev[x,y])
{
dz=(elev[ml1x,ml1y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*2*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[ml1x,ml1y]-amount)<(bedrock[ml1x,ml1y]))amount=(elev[ml1x,ml1y]-(bedrock[ml1x,ml1y]));
if(amount<0)amount=0;
if(water_depth[ml1x_rec,ml1y_rec]>0.0001)
{
elev[ml1x_rec,ml1y_rec]+=amount;
elev[ml1x,ml1y]-=amount;
slide_GS(ml1x,ml1y,amount,ml1x_rec,ml1y_rec);
}
else
{
elev[x,y]+=amount;
elev[ml1x,ml1y]-=amount;
slide_GS(ml1x,ml1y,amount,x,y);
}
}
if(elev[ml2x,ml2y]>elev[x,y])
{
dz=(elev[ml2x,ml2y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*2*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[ml2x,ml2y]-amount)<(bedrock[ml2x,ml2y]))amount=(elev[ml2x,ml2y]-(bedrock[ml2x,ml2y]));
if(amount<0)amount=0;
if(water_depth[ml1x_rec,ml1y_rec]>0.0001)
{
elev[ml1x_rec,ml1y_rec]+=amount;
elev[ml2x,ml2y]-=amount;
slide_GS(ml2x,ml2y,amount,ml1x_rec,ml1y_rec);
}
else
{
elev[x,y]+=amount;
elev[ml2x,ml2y]-=amount;
slide_GS(ml2x,ml2y,amount,x,y);
}
}
if(elev[ml3x,ml3y]>elev[x,y])
{
dz=(elev[ml3x,ml3y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*2*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[ml3x,ml3y]-amount)<(bedrock[ml3x,ml3y]))amount=(elev[ml3x,ml3y]-(bedrock[ml3x,ml3y]));
if(amount<0)amount=0;
if(water_depth[ml1x_rec,ml1y_rec]>0.0001)
{
elev[ml1x_rec,ml1y_rec]+=amount;
elev[ml3x,ml3y]-=amount;
slide_GS(ml3x,ml3y,amount,ml1x_rec,ml1y_rec);
}
else
{
elev[x,y]+=amount;
elev[ml3x,ml3y]-=amount;
slide_GS(ml3x,ml3y,amount,x,y);
}
}
}
if(flow_dir[x,y,1]==el)
{
/* do easy left erosion */
if(elev[ml1x,ml1y]>elev[x,y])
{
dz=(elev[ml1x,ml1y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*1*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[ml1x,ml1y]-amount)<(bedrock[ml1x,ml1y]))amount=(elev[ml1x,ml1y]-(bedrock[ml1x,ml1y]));
if(amount<0)amount=0;
if(water_depth[ml1x_rec,ml1y_rec]>0.0001)
{
elev[ml1x_rec,ml1y_rec]+=amount;
elev[ml1x,ml1y]-=amount;
slide_GS(ml1x,ml1y,amount,ml1x_rec,ml1y_rec);
}
else
{
elev[x,y]+=amount;
elev[ml1x,ml1y]-=amount;
slide_GS(ml1x,ml1y,amount,x,y);
}
}
if(elev[ml2x,ml2y]>elev[x,y])
{
dz=(elev[ml2x,ml2y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*1*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[ml2x,ml2y]-amount)<(bedrock[ml2x,ml2y]))amount=(elev[ml2x,ml2y]-(bedrock[ml2x,ml2y]));
if(amount<0)amount=0;
if(water_depth[ml1x_rec,ml1y_rec]>0.0001)
{
elev[ml1x_rec,ml1y_rec]+=amount;
elev[ml2x,ml2y]-=amount;
slide_GS(ml2x,ml2y,amount,ml1x_rec,ml1y_rec);
}
else
{
elev[x,y]+=amount;
elev[ml2x,ml2y]-=amount;
slide_GS(ml2x,ml2y,amount,x,y);
}
}
if(elev[ml3x,ml3y]>elev[x,y])
{
dz=(elev[ml3x,ml3y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*1*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[ml3x,ml3y]-amount)<(bedrock[ml3x,ml3y]))amount=(elev[ml3x,ml3y]-(bedrock[ml3x,ml3y]));
if(amount<0)amount=0;
if(water_depth[ml1x_rec,ml1y_rec]>0.0001)
{
elev[ml1x_rec,ml1y_rec]+=amount;
elev[ml3x,ml3y]-=amount;
slide_GS(ml3x,ml3y,amount,ml1x_rec,ml1y_rec);
}
else
{
elev[x,y]+=amount;
elev[ml3x,ml3y]-=amount;
slide_GS(ml3x,ml3y,amount,x,y);
}
}
}
/****** right bend erosion ****/
if(flow_dir[x,y,1]==mr)
{
/* do medium right erosion */
if(elev[mr1x,mr1y]>elev[x,y])
{
dz=(elev[mr1x,mr1y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*2*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[mr1x,mr1y]-amount)<(bedrock[mr1x,mr1y]))amount=(elev[mr1x,mr1y]-(bedrock[mr1x,mr1y]));
if(amount<0)amount=0;
if(water_depth[mr1x_rec,mr1y_rec]>0.0001)
{
elev[mr1x_rec,mr1y_rec]+=amount;
elev[mr1x,mr1y]-=amount;
slide_GS(mr1x,mr1y,amount,mr1x_rec,mr1y_rec);
}
else
{
elev[x,y]+=amount;
elev[mr1x,mr1y]-=amount;
slide_GS(mr1x,mr1y,amount,x,y);
}
}
if(elev[mr2x,mr2y]>elev[x,y])
{
dz=(elev[mr2x,mr2y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*2*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[mr2x,mr2y]-amount)<(bedrock[mr2x,mr2y]))amount=(elev[mr2x,mr2y]-(bedrock[mr2x,mr2y]));
if(amount<0)amount=0;
if(water_depth[mr1x_rec,mr1y_rec]>0.0001)
{
elev[mr1x_rec,mr1y_rec]+=amount;
elev[mr2x,mr2y]-=amount;
slide_GS(mr2x,mr2y,amount,mr1x_rec,mr1y_rec);
}
else
{
elev[x,y]+=amount;
elev[mr2x,mr2y]-=amount;
slide_GS(mr2x,mr2y,amount,x,y);
}
}
if(elev[mr3x,mr3y]>elev[x,y])
{
dz=(elev[mr3x,mr3y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*2*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[mr3x,mr3y]-amount)<(bedrock[mr3x,mr3y]))amount=(elev[mr3x,mr3y]-(bedrock[mr3x,mr3y]));
if(amount<0)amount=0;
if(water_depth[mr1x_rec,mr1y_rec]>0.0001)
{
elev[mr1x_rec,mr1y_rec]+=amount;
elev[mr3x,mr3y]-=amount;
slide_GS(mr3x,mr3y,amount,mr1x_rec,mr1y_rec);
}
else
{
elev[x,y]+=amount;
elev[mr3x,mr3y]-=amount;
slide_GS(mr3x,mr3y,amount,x,y);
}
}
}
/* do easy right erosion */
if(flow_dir[x,y,1]==er)
{
if(elev[mr1x,mr1y]>elev[x,y])
{
dz=(elev[mr1x,mr1y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*1*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[mr1x,mr1y]-amount)<(bedrock[mr1x,mr1y]))amount=(elev[mr1x,mr1y]-(bedrock[mr1x,mr1y]));
if(amount<0)amount=0;
if(water_depth[mr1x_rec,mr1y_rec]>0.0001)
{
elev[mr1x_rec,mr1y_rec]+=amount;
elev[mr1x,mr1y]-=amount;
slide_GS(mr1x,mr1y,amount,mr1x_rec,mr1y_rec);
}
else
{
elev[x,y]+=amount;
elev[mr1x,mr1y]-=amount;
slide_GS(mr1x,mr1y,amount,x,y);
}
}
if(elev[mr2x,mr2y]>elev[x,y])
{
dz=(elev[mr2x,mr2y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*1*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[mr2x,mr2y]-amount)<(bedrock[mr2x,mr2y]))amount=(elev[mr2x,mr2y]-(bedrock[mr2x,mr2y]));
if(amount<0)amount=0;
if(water_depth[mr1x_rec,mr1y_rec]>0.0001)
{
elev[mr1x_rec,mr1y_rec]+=amount;
elev[mr2x,mr2y]-=amount;
slide_GS(mr2x,mr2y,amount,mr1x_rec,mr1y_rec);
}
else
{
elev[x,y]+=amount;
elev[mr2x,mr2y]-=amount;
slide_GS(mr2x,mr2y,amount,x,y);
}
}
if(elev[mr3x,mr3y]>elev[x,y])
{
dz=(elev[mr3x,mr3y]-elev[x,y]);
amount=(max_flow[x,y,0]/(water_depth[x,y]*DX))*1*dz*time_factor*lateral_constant;
amount=amount/DX;
if((elev[mr3x,mr3y]-amount)<(bedrock[mr3x,mr3y]))amount=(elev[mr3x,mr3y]-(bedrock[mr3x,mr3y]));
if(amount<0)amount=0;
if(water_depth[mr1x_rec,mr1y_rec]>0.0001)
{
elev[mr1x_rec,mr1y_rec]+=amount;
elev[mr3x,mr3y]-=amount;
slide_GS(mr3x,mr3y,amount,mr1x_rec,mr1y_rec);
}
else
{
elev[x,y]+=amount;
elev[mr3x,mr3y]-=amount;
slide_GS(mr3x,mr3y,amount,x,y);
}
}
}
}
}
}
// this section zeros the water depths, as well as the flow directions, ready for the next iteration
for(y=ymax;y>=1;y--)
{
inc=1;
while(down_scan[y,inc]>0)
{
x=down_scan[y,inc];
inc++;
flow_dir[x,y,0]=0;
flow_dir[x,y,1]=0;
for(n=0;n<=8;n++)
{
max_flow[x,y,n]=0;
}
old_water_depth[x,y]=water_depth[x,y];
if(water_depth[x,y]>0)water_depth[x,y]=0;
qcounter[x,y]=0;
lat_vol[x,y]=discharge[x,y];
left_in[x,y]=0;
left_out[x,y]=0;
right_in[x,y]=0;
right_out[x,y]=0;
up_in[x,y]=0;
up_out[x,y]=0;
down_in[x,y]=0;
down_out[x,y]=0;
Tau[x, y] = 0;
// this line also reduces part of the remaining Qw - a kind of evaporation
// else you can end up with trapped bodies of water..
// altered by MJ 15/03/05 - parameterized evaporation
if ((k_evap > 0.0) && (discharge[x,y] > 0.0))
{
discharge[x,y] -= time_factor * k_evap * (DX*DX);
if (discharge[x,y] < 0.0) discharge[x,y] = 0.0;
}
}
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
HttpWebRequest req;
HttpWebResponse res;
try
{
req = (HttpWebRequest) WebRequest.Create("http://www.coulthard.org.uk/");
res = (HttpWebResponse) req.GetResponse();
}
catch(Exception ex)
{
/// do nothing.
}
//JMW <20040929 -start>
this.Text = basetext;
//DoingGraphics = false;
//JMW <20040929 - end>
}
void button1_Click(object sender, System.EventArgs e)
{
save_data(1,9999);
try
{
if (checkBoxGenerateAVIFile.Checked)
aw.Close(); //JMW 20041109
}
catch(Exception ex)
{
/// do nothing.
}
this.Close();
}
private void button2_Click(object sender, System.EventArgs e)
{
int ok;
ok = read_header();
if (ok == 1)
{
initialise();
zero_values();
load_data();
// nActualGridSize
// moved from initialse() to here MJ 29/03/05
int x,y;
nActualGridCells = 0;
for(x=1;x<=xmax;x++)
{
for(y=1;y<=ymax;y++)
{
if (elev[x,y] > -999) nActualGridCells++;
}
}
tabControl1.Visible = false; // MJ 14/01/05
Panel1.Visible = true; // MJ 14/01/05
button2.Enabled = false; // MJ 17/01/05
start_button.Enabled = true; // MJ 17/01/05
}
}
private void textBox2_TextChanged(object sender, System.EventArgs e)
{
}
private void contextMenu1_Popup(object sender, System.EventArgs e)
{
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
menuItem3.Checked=(!menuItem3.Checked);
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
menuItem4.Checked=(!menuItem4.Checked);
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
menuItem5.Checked=(!menuItem5.Checked);
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
menuItem6.Checked=(!menuItem6.Checked);
}
private void menuItem7_Click(object sender, System.EventArgs e)
{
menuItem7.Checked=(!menuItem7.Checked);
}
private void menuItem8_Click(object sender, System.EventArgs e)
{
menuItem8.Checked=(!menuItem8.Checked);
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
menuItem9.Checked=(!menuItem9.Checked);
}
private void menuItem10_Click(object sender, System.EventArgs e)
{
menuItem10.Checked=(!menuItem10.Checked);
}
private void menuItem19_Click(object sender, System.EventArgs e)
{
menuItem19.Checked=(!menuItem19.Checked);
}
private void menuItem12_Click(object sender, System.EventArgs e)
{
menuItem12.Checked=(!menuItem12.Checked);
}
private void menuItem13_Click(object sender, System.EventArgs e)
{
menuItem13.Checked=(!menuItem13.Checked);
}
private void menuItem14_Click(object sender, System.EventArgs e)
{
menuItem14.Checked=(!menuItem14.Checked);
}
private void menuItem15_Click(object sender, System.EventArgs e)
{
menuItem15.Checked=(!menuItem15.Checked);
}
private void menuItem16_Click(object sender, System.EventArgs e)
{
menuItem16.Checked=(!menuItem16.Checked);
}
private void menuItem17_Click(object sender, System.EventArgs e)
{
menuItem17.Checked=(!menuItem17.Checked);
}
private void menuItem18_Click(object sender, System.EventArgs e)
{
menuItem18.Checked=(!menuItem18.Checked);
}
private void menuItem20_Click(object sender, System.EventArgs e)
{
menuItem20.Checked=(!menuItem20.Checked);
}
private void menuItem21_Click(object sender, System.EventArgs e)
{
menuItem21.Checked=(!menuItem21.Checked);
}
private void menuItem22_Click(object sender, System.EventArgs e)
{
menuItem22.Checked=(!menuItem22.Checked);
}
private void menuItem23_Click(object sender, System.EventArgs e)
{
menuItem23.Checked=(!menuItem23.Checked);
}
private void menuItem24_Click(object sender, System.EventArgs e)
{
menuItem24.Checked=(!menuItem24.Checked);
}
private void menuItem25_Click(object sender, System.EventArgs e)
{
menuItem25.Checked=(!menuItem25.Checked);
}
private void menuItem26_Click(object sender, System.EventArgs e)
{
menuItem26.Checked=(!menuItem26.Checked);
}
private void menuItem27_Click(object sender, System.EventArgs e)
{
menuItem27.Checked=(!menuItem27.Checked);
}
private void menuItem28_Click(object sender, System.EventArgs e)
{
menuItem28.Checked=(!menuItem28.Checked);
}
private void menuItem29_Click(object sender, System.EventArgs e)
{
menuItem29.Checked=(!menuItem29.Checked);
}
private void menuItem30_Click(object sender, System.EventArgs e)
{
menuItem30.Checked=(!menuItem30.Checked);
}
private void menuItem31_Click(object sender, System.EventArgs e)
{
menuItem31.Checked=(!menuItem31.Checked);
}
private void menuItem32_Click(object sender, System.EventArgs e)
{
menuItem32.Checked=(!menuItem32.Checked);
}
private void menuItem33_Click(object sender, System.EventArgs e)
{
menuItem33.Checked=(!menuItem33.Checked);
}
private void menuItem34_Click(object sender, System.EventArgs e)
{
menuItem34.Checked=(!menuItem34.Checked);
}
private void button3_Click(object sender, System.EventArgs e)
{
grow_grass(1);
}
private void menuItemConfigFileOpen_Click(object sender, System.EventArgs e)
{
XmlTextReader xreader;
String dum;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = workdir ;
openFileDialog1.Filter = "cfg files (*.xml)|*.xml|All files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 1 ;
openFileDialog1.RestoreDirectory = false ;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
cfgname = openFileDialog1.FileName;
xreader = new XmlTextReader(cfgname);
//Read the file
if (xreader != null)
{
xreader.ReadStartElement("Parms");
xreader.ReadStartElement("General-Parms");
try
{
overrideheaderBox.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("headeroverride"));
}
catch
{};
xtextbox.Text = xreader.ReadElementString("x-coordinate");
ytextbox.Text = xreader.ReadElementString("y-coordinate");
initscansbox.Text = xreader.ReadElementString("initscans");
erodefactorbox.Text = xreader.ReadElementString("maxerodelimit");
dxbox.Text = xreader.ReadElementString("cellsize");
limitbox.Text = xreader.ReadElementString("memorylimit");
minqbox.Text = xreader.ReadElementString("minq");
creepratebox.Text = xreader.ReadElementString("creeprate");
lateralratebox.Text = xreader.ReadElementString("lateralerosionrate");
itermaxbox.Text = xreader.ReadElementString("maxiter");
textBox1.Text = xreader.ReadElementString("runstarttime");
cyclemaxbox.Text = xreader.ReadElementString("maxrunduration");
slopebox.Text = xreader.ReadElementString("slopefailurethreshold");
smoothbox.Text = xreader.ReadElementString("wssmoothingradius");
mvaluebox.Text = xreader.ReadElementString("mvalue");
grasstextbox.Text = xreader.ReadElementString("growgrasstime");
textBox2.Text = xreader.ReadElementString("initialq");
checkBox3.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("wssmoothing"));
grassbox.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("grass-sediment"));
try // MJ 24/01/05
{
textBox3.Text = xreader.ReadElementString("flowdistribution");
mintimestepbox.Text = xreader.ReadElementString("mintimestep");
}
catch
{};
try // MJ 15/03/05
{
k_evapBox.Text = xreader.ReadElementString("evaporation");
}
catch
{};
try // MJ 10/05/05
{
vegTauCritBox.Text = xreader.ReadElementString("vegcritshear");
}
catch
{};
try
{
bedslope_box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("bedslope"));
}
catch
{};
try
{
wslope_box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("wsslope"));
}
catch
{};
try
{
veltaubox.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("veltaubox"));
}
catch
{ };
try
{
catchment_mode_box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("catchment_mode"));
}
catch
{};
try
{
reach_mode_box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("reach_mode"));
}
catch
{};
try
{
latbox1.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("lat1"));
}
catch
{};
try
{
latbox2.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("lat2"));
}
catch
{};
try
{
latbox3.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("lat3"));
}
catch
{};
try
{
cross_stream_grad_box.Text = xreader.ReadElementString("cross_stream_grad");
}
catch
{};
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem12.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem13.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem14.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem15.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem16.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem17.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem18.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem19.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem20.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem21.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem22.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem23.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem24.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem25.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
try
{
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem29.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem33.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
xreader.ReadStartElement("SaveOptions");
dum = xreader.ReadElementString("Option");
menuItem34.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("Checked"));
xreader.ReadEndElement();
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Grain-Size");
g1box.Text = xreader.ReadElementString("gs");
gp1box.Text = xreader.ReadElementString("gp");
try
{
suspGS1box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS1box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Grain-Size");
g2box.Text = xreader.ReadElementString("gs");
gp2box.Text = xreader.ReadElementString("gp");
try
{
suspGS2box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS2box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Grain-Size");
g3box.Text = xreader.ReadElementString("gs");
gp3box.Text = xreader.ReadElementString("gp");
try
{
suspGS3box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS3box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Grain-Size");
g4box.Text = xreader.ReadElementString("gs");
gp4box.Text = xreader.ReadElementString("gp");
try
{
suspGS4box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS4box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Grain-Size");
g5box.Text = xreader.ReadElementString("gs");
gp5box.Text = xreader.ReadElementString("gp");
try
{
suspGS5box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS5box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Grain-Size");
g6box.Text = xreader.ReadElementString("gs");
gp6box.Text = xreader.ReadElementString("gp");
try
{
suspGS6box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS6box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Grain-Size");
g7box.Text = xreader.ReadElementString("gs");
gp7box.Text = xreader.ReadElementString("gp");
try
{
suspGS7box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS7box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Grain-Size");
g8box.Text = xreader.ReadElementString("gs");
gp8box.Text = xreader.ReadElementString("gp");
try
{
suspGS8box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS8box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
try
{
xreader.ReadStartElement("Grain-Size");
g9box.Text = xreader.ReadElementString("gs");
gp9box.Text = xreader.ReadElementString("gp");
try
{
suspGS9box.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ss"));
fallGS9box.Text = xreader.ReadElementString("fv");
}
catch
{};
xreader.ReadEndElement();
}
catch
{};
xreader.ReadStartElement("File-Parms");
input_time_step_box.Text = xreader.ReadElementString("inputtimestep");
saveintervalbox.Text = xreader.ReadElementString("saveinterval");
outputfilesaveintervalbox.Text = xreader.ReadElementString("savetologfileinterval");
tracerbox.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("tracerrun"));
uniquefilecheck.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("uniquefilecheck"));
xreader.ReadStartElement("Filenames");
dum = xreader.ReadElementString("Desc");
openfiletextbox.Text = xreader.ReadElementString("Name");
xreader.ReadEndElement();
xreader.ReadStartElement("Filenames");
dum = xreader.ReadElementString("Desc");
graindataloadbox.Text = xreader.ReadElementString("Name");
xreader.ReadEndElement();
xreader.ReadStartElement("Filenames");
dum = xreader.ReadElementString("Desc");
bedrockbox.Text = xreader.ReadElementString("Name");
xreader.ReadEndElement();
xreader.ReadStartElement("Filenames");
dum = xreader.ReadElementString("Desc");
raindataloadbox.Text = xreader.ReadElementString("Name");
xreader.ReadEndElement();
xreader.ReadStartElement("Filenames");
dum = xreader.ReadElementString("Desc");
tracerfile.Text = xreader.ReadElementString("Name");
xreader.ReadEndElement();
xreader.ReadStartElement("Filenames");
dum = xreader.ReadElementString("Desc");
tracerhydrofile.Text = xreader.ReadElementString("Name");
xreader.ReadEndElement();
xreader.ReadStartElement("Filenames");
dum = xreader.ReadElementString("Desc");
tracergrainbox.Text = xreader.ReadElementString("Name");
xreader.ReadEndElement();
try{
xreader.ReadStartElement("Sources");
inbox1.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("input"));
xbox1.Text = xreader.ReadElementString("X");
ybox1.Text = xreader.ReadElementString("Y");
infile1.Text = xreader.ReadElementString("Filename");
xreader.ReadEndElement();
xreader.ReadStartElement("Sources");
inbox2.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("input"));
xbox2.Text = xreader.ReadElementString("X");
ybox2.Text = xreader.ReadElementString("Y");
infile2.Text = xreader.ReadElementString("Filename");
xreader.ReadEndElement();
xreader.ReadStartElement("Sources");
inbox3.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("input"));
xbox3.Text = xreader.ReadElementString("X");
ybox3.Text = xreader.ReadElementString("Y");
infile3.Text = xreader.ReadElementString("Filename");
xreader.ReadEndElement();
xreader.ReadStartElement("Sources");
inbox4.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("input"));
xbox4.Text = xreader.ReadElementString("X");
ybox4.Text = xreader.ReadElementString("Y");
infile4.Text = xreader.ReadElementString("Filename");
xreader.ReadEndElement();
xreader.ReadStartElement("Sources");
inbox5.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("input"));
xbox5.Text = xreader.ReadElementString("X");
ybox5.Text = xreader.ReadElementString("Y");
infile5.Text = xreader.ReadElementString("Filename");
xreader.ReadEndElement();
xreader.ReadStartElement("Sources");
inbox6.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("input"));
xbox6.Text = xreader.ReadElementString("X");
ybox6.Text = xreader.ReadElementString("Y");
infile6.Text = xreader.ReadElementString("Filename");
xreader.ReadEndElement();
xreader.ReadStartElement("Sources");
inbox7.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("input"));
xbox7.Text = xreader.ReadElementString("X");
ybox7.Text = xreader.ReadElementString("Y");
infile7.Text = xreader.ReadElementString("Filename");
xreader.ReadEndElement();
xreader.ReadStartElement("Sources");
inbox8.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("input"));
xbox8.Text = xreader.ReadElementString("X");
ybox8.Text = xreader.ReadElementString("Y");
infile8.Text = xreader.ReadElementString("Filename");
xreader.ReadEndElement();
}
catch
{};
xreader.ReadEndElement();
xreader.ReadStartElement("Description");
DescBox.Text = xreader.ReadElementString("S");
xreader.ReadEndElement();
//JMW 2004-11-11
try
{
xreader.ReadStartElement("OutputFile-Parms");
checkBoxGenerateAVIFile.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("generateavifile"));
textBoxAVIFile.Text = xreader.ReadElementString("avifile");
try
{
saveintervalbox.Text = xreader.ReadElementString("avifreq");
checkBoxGenerateTimeSeries.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("generatetimeseriesfile"));
TimeseriesOutBox.Text = xreader.ReadElementString("timeseriesfile");
outputfilesaveintervalbox.Text = xreader.ReadElementString("timeseriesfreq");
checkBoxGenerateIterations.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("generateiterationsfile"));
IterationOutbox.Text = xreader.ReadElementString("iterationsfile");
}
catch
{};
xreader.ReadEndElement();
}
catch
{};
try
{
xreader.ReadStartElement("Display");
Form1.ActiveForm.Top = XmlConvert.ToInt16(xreader.ReadElementString("top"));
Form1.ActiveForm.Left = XmlConvert.ToInt16(xreader.ReadElementString("left"));
Form1.ActiveForm.Width = XmlConvert.ToInt16(xreader.ReadElementString("width"));
Form1.ActiveForm.Height = XmlConvert.ToInt16(xreader.ReadElementString("height"));
xreader.ReadEndElement();
}
catch
{};
try
{
xreader.ReadStartElement("Lateral");
oldlateral.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("oldlat"));
newlateral.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("newlat"));
xreader.ReadEndElement();
}
catch
{};
xreader.ReadEndElement();
xreader.Close();
this.Text = basetext + " (" + Path.GetFileName(cfgname) + ")";
button2.Enabled = true;
start_button.Enabled = false;
Panel1.Visible = false;
tabControl1.Visible = true;
}
}
}
// JMW - Config File Save & SaveAs Event Handler
private void menuItemConfigFileSave_Click(object sender, System.EventArgs e)
{
XmlTextWriter xwriter;
if ((sender == menuItemConfigFileSaveAs) || (cfgname == null))
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = workdir ;
saveFileDialog1.Filter = "cfg files (*.xml)|*.xml|All files (*.*)|*.*" ;
saveFileDialog1.FilterIndex = 1 ;
saveFileDialog1.RestoreDirectory = false ;
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
cfgname = saveFileDialog1.FileName;
}
}
if (cfgname != null)
{
//Create a new XmlTextWriter.
xwriter = new XmlTextWriter(cfgname,System.Text.Encoding.UTF8);
//Write the beginning of the document including the
//document declaration. Standalone is true.
//Use indentation for readability.
xwriter.Formatting = Formatting.Indented;
xwriter.Indentation = 4;
xwriter.WriteStartDocument(true);
//Write the beginning of the "data" element. This is
//the opening tag to our data
xwriter.WriteStartElement("Parms");
xwriter.WriteStartElement("General-Parms");
xwriter.WriteElementString("headeroverride",XmlConvert.ToString(overrideheaderBox.Checked));
xwriter.WriteElementString("x-coordinate",xtextbox.Text);
xwriter.WriteElementString("y-coordinate",ytextbox.Text);
xwriter.WriteElementString("initscans",initscansbox.Text);
xwriter.WriteElementString("maxerodelimit",erodefactorbox.Text);
xwriter.WriteElementString("cellsize",dxbox.Text);
xwriter.WriteElementString("memorylimit",limitbox.Text);
xwriter.WriteElementString("minq",minqbox.Text);
xwriter.WriteElementString("creeprate",creepratebox.Text);
xwriter.WriteElementString("lateralerosionrate",lateralratebox.Text);
xwriter.WriteElementString("maxiter",itermaxbox.Text);
xwriter.WriteElementString("runstarttime",textBox1.Text);
xwriter.WriteElementString("maxrunduration",cyclemaxbox.Text);
xwriter.WriteElementString("slopefailurethreshold",slopebox.Text);
xwriter.WriteElementString("wssmoothingradius",smoothbox.Text);
xwriter.WriteElementString("mvalue",mvaluebox.Text);
xwriter.WriteElementString("growgrasstime",grasstextbox.Text);
xwriter.WriteElementString("initialq",textBox2.Text);
xwriter.WriteElementString("wssmoothing",XmlConvert.ToString(checkBox3.Checked));
xwriter.WriteElementString("grass-sediment",XmlConvert.ToString(grassbox.Checked));
xwriter.WriteElementString("flowdistribution",textBox3.Text); // MJ 24/01/05
xwriter.WriteElementString("mintimestep",mintimestepbox.Text); // MJ 24/01/05
xwriter.WriteElementString("evaporation",k_evapBox.Text); // MJ 15/03/05
xwriter.WriteElementString("vegcritshear",vegTauCritBox.Text); // MJ 10/05/05
xwriter.WriteElementString("bedslope",XmlConvert.ToString(bedslope_box.Checked));
xwriter.WriteElementString("wsslope",XmlConvert.ToString(wslope_box.Checked));
xwriter.WriteElementString("veltaubox", XmlConvert.ToString(veltaubox.Checked));
xwriter.WriteElementString("catchment_mode",XmlConvert.ToString(catchment_mode_box.Checked));
xwriter.WriteElementString("reach_mode",XmlConvert.ToString(reach_mode_box.Checked));
xwriter.WriteElementString("lat1",XmlConvert.ToString(latbox1.Checked));
xwriter.WriteElementString("lat2",XmlConvert.ToString(latbox2.Checked));
xwriter.WriteElementString("lat3",XmlConvert.ToString(latbox3.Checked));
xwriter.WriteElementString("cross_stream_grad",cross_stream_grad_box.Text);
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","elevations");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem12.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","elevdiff");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem13.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","grainsize");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem14.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","total tracer g/s");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem15.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 1");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem16.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 2");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem17.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 3");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem18.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 4");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem19.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 5");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem20.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 6");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem21.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 7");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem22.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 8");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem23.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","tracer layer 9");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem24.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","water depth");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem25.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","d50");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem29.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","flow velocity");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem33.Checked));
xwriter.WriteEndElement();
xwriter.WriteStartElement("SaveOptions");
xwriter.WriteElementString("Option","soil saturation");
xwriter.WriteElementString("Checked",XmlConvert.ToString(menuItem34.Checked));
xwriter.WriteEndElement();
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g1box.Text);
xwriter.WriteElementString("gp",gp1box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS1box.Checked));
xwriter.WriteElementString("fv",fallGS1box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g2box.Text);
xwriter.WriteElementString("gp",gp2box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS2box.Checked));
xwriter.WriteElementString("fv",fallGS2box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g3box.Text);
xwriter.WriteElementString("gp",gp3box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS3box.Checked));
xwriter.WriteElementString("fv",fallGS3box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g4box.Text);
xwriter.WriteElementString("gp",gp4box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS4box.Checked));
xwriter.WriteElementString("fv",fallGS4box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g5box.Text);
xwriter.WriteElementString("gp",gp5box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS5box.Checked));
xwriter.WriteElementString("fv",fallGS5box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g6box.Text);
xwriter.WriteElementString("gp",gp6box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS6box.Checked));
xwriter.WriteElementString("fv",fallGS6box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g7box.Text);
xwriter.WriteElementString("gp",gp7box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS7box.Checked));
xwriter.WriteElementString("fv",fallGS7box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g8box.Text);
xwriter.WriteElementString("gp",gp8box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS8box.Checked));
xwriter.WriteElementString("fv",fallGS8box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Grain-Size");
xwriter.WriteElementString("gs",g9box.Text);
xwriter.WriteElementString("gp",gp9box.Text);
xwriter.WriteElementString("ss",XmlConvert.ToString(suspGS9box.Checked));
xwriter.WriteElementString("fv",fallGS9box.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("File-Parms");
xwriter.WriteElementString("inputtimestep",input_time_step_box.Text);
xwriter.WriteElementString("saveinterval",saveintervalbox.Text);
xwriter.WriteElementString("savetologfileinterval",outputfilesaveintervalbox.Text);
xwriter.WriteElementString("tracerrun",XmlConvert.ToString(tracerbox.Checked));
xwriter.WriteElementString("uniquefilecheck",XmlConvert.ToString(uniquefilecheck.Checked));
xwriter.WriteStartElement("Filenames");
xwriter.WriteElementString("Desc","DEM Data File");
xwriter.WriteElementString("Name",openfiletextbox.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Filenames");
xwriter.WriteElementString("Desc","Grain Data File");
xwriter.WriteElementString("Name",graindataloadbox.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Filenames");
xwriter.WriteElementString("Desc","Bedrock Data File");
xwriter.WriteElementString("Name",bedrockbox.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Filenames");
xwriter.WriteElementString("Desc","Rain Data File");
xwriter.WriteElementString("Name",raindataloadbox.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Filenames");
xwriter.WriteElementString("Desc","Tracer File");
xwriter.WriteElementString("Name",tracerfile.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Filenames");
xwriter.WriteElementString("Desc","Tracer Sed Vol File");
xwriter.WriteElementString("Name",tracerhydrofile.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Filenames");
xwriter.WriteElementString("Desc","Tracer Grain Size Data File");
xwriter.WriteElementString("Name",tracergrainbox.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Sources");
xwriter.WriteElementString("input",XmlConvert.ToString(inbox1.Checked));
xwriter.WriteElementString("X",xbox1.Text);
xwriter.WriteElementString("Y",ybox1.Text);
xwriter.WriteElementString("Filename",infile1.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Sources");
xwriter.WriteElementString("input",XmlConvert.ToString(inbox2.Checked));
xwriter.WriteElementString("X",xbox2.Text);
xwriter.WriteElementString("Y",ybox2.Text);
xwriter.WriteElementString("Filename",infile2.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Sources");
xwriter.WriteElementString("input",XmlConvert.ToString(inbox3.Checked));
xwriter.WriteElementString("X",xbox3.Text);
xwriter.WriteElementString("Y",ybox3.Text);
xwriter.WriteElementString("Filename",infile3.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Sources");
xwriter.WriteElementString("input",XmlConvert.ToString(inbox4.Checked));
xwriter.WriteElementString("X",xbox4.Text);
xwriter.WriteElementString("Y",ybox4.Text);
xwriter.WriteElementString("Filename",infile4.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Sources");
xwriter.WriteElementString("input",XmlConvert.ToString(inbox5.Checked));
xwriter.WriteElementString("X",xbox5.Text);
xwriter.WriteElementString("Y",ybox5.Text);
xwriter.WriteElementString("Filename",infile5.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Sources");
xwriter.WriteElementString("input",XmlConvert.ToString(inbox6.Checked));
xwriter.WriteElementString("X",xbox6.Text);
xwriter.WriteElementString("Y",ybox6.Text);
xwriter.WriteElementString("Filename",infile6.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Sources");
xwriter.WriteElementString("input",XmlConvert.ToString(inbox7.Checked));
xwriter.WriteElementString("X",xbox7.Text);
xwriter.WriteElementString("Y",ybox7.Text);
xwriter.WriteElementString("Filename",infile7.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Sources");
xwriter.WriteElementString("input",XmlConvert.ToString(inbox8.Checked));
xwriter.WriteElementString("X",xbox8.Text);
xwriter.WriteElementString("Y",ybox8.Text);
xwriter.WriteElementString("Filename",infile8.Text);
xwriter.WriteEndElement();
xwriter.WriteEndElement();
xwriter.WriteStartElement("Description");
xwriter.WriteElementString("S",DescBox.Text);
xwriter.WriteEndElement();
//JMW 2004-11-11; updated MJ 24/01/05
xwriter.WriteStartElement("OutputFile-Parms");
xwriter.WriteElementString("generateavifile",XmlConvert.ToString(checkBoxGenerateAVIFile.Checked));
xwriter.WriteElementString("avifile",textBoxAVIFile.Text);
xwriter.WriteElementString("avifreq",saveintervalbox.Text);
xwriter.WriteElementString("generatetimeseriesfile",XmlConvert.ToString(checkBoxGenerateTimeSeries.Checked));
xwriter.WriteElementString("timeseriesfile",TimeseriesOutBox.Text);
xwriter.WriteElementString("timeseriesfreq",outputfilesaveintervalbox.Text);
xwriter.WriteElementString("generateiterationsfile",XmlConvert.ToString(checkBoxGenerateIterations.Checked));
xwriter.WriteElementString("iterationsfile",IterationOutbox.Text);
xwriter.WriteEndElement();
xwriter.WriteStartElement("Display");
xwriter.WriteElementString("top",string.Format(" {0}",Form1.ActiveForm.Top));
xwriter.WriteElementString("left",string.Format(" {0}",Form1.ActiveForm.Left));
xwriter.WriteElementString("width",string.Format(" {0}",Form1.ActiveForm.Width));
xwriter.WriteElementString("height",string.Format(" {0}",Form1.ActiveForm.Height));
xwriter.WriteEndElement();
xwriter.WriteStartElement("Lateral");
xwriter.WriteElementString("oldlat",XmlConvert.ToString(oldlateral.Checked));
xwriter.WriteElementString("newlat",XmlConvert.ToString(newlateral.Checked));
xwriter.WriteEndElement();
xwriter.WriteEndElement();
//End the document
xwriter.WriteEndDocument();
//Flush the xml document to the underlying stream and
//close the underlying stream. The data will not be
//written out to the stream until either the Flush()
//method is called or the Close() method is called.
xwriter.Close();
this.Text = basetext + " (" + Path.GetFileName(cfgname) + ")";
}
}
private void suspCheckedChange(object sender, System.EventArgs e)
{
fallGS1box.Enabled = suspGS1box.Checked;
fallGS2box.Enabled = suspGS2box.Checked;
fallGS3box.Enabled = suspGS3box.Checked;
fallGS4box.Enabled = suspGS4box.Checked;
fallGS5box.Enabled = suspGS5box.Checked;
fallGS6box.Enabled = suspGS6box.Checked;
fallGS7box.Enabled = suspGS7box.Checked;
fallGS8box.Enabled = suspGS8box.Checked;
fallGS9box.Enabled = suspGS9box.Checked;
}
private void fracGSchanged(object sender, System.EventArgs e)
{
double sum;
sum = 0.0;
if (gp1box.Text != "") sum += double.Parse(gp1box.Text);
if (gp2box.Text != "") sum += double.Parse(gp2box.Text);
if (gp3box.Text != "") sum += double.Parse(gp3box.Text);
if (gp4box.Text != "") sum += double.Parse(gp4box.Text);
if (gp5box.Text != "") sum += double.Parse(gp5box.Text);
if (gp6box.Text != "") sum += double.Parse(gp6box.Text);
if (gp7box.Text != "") sum += double.Parse(gp7box.Text);
if (gp8box.Text != "") sum += double.Parse(gp8box.Text);
if (gp9box.Text != "") sum += double.Parse(gp9box.Text);
if (Math.Abs(sum-1.0) < 0.000000001)
{
gpSumLabel.Text = "OK";
gpSumLabel.ForeColor = Color.Black;
gpSumLabel2.ForeColor = Color.Black;
}
else
{
gpSumLabel.Text = string.Format("{0:F8}",sum);
gpSumLabel.ForeColor = Color.Red;
gpSumLabel2.ForeColor = Color.Red;
}
}
private void button4_Click_1(object sender, System.EventArgs e)
{
this.Refresh();
drawwater(mygraphics);
}
private void overrideheaderBox_CheckedChanged(object sender, System.EventArgs e)
{
label1.Enabled = overrideheaderBox.Checked;
label2.Enabled = overrideheaderBox.Checked;
label11.Enabled = overrideheaderBox.Checked;
xtextbox.Enabled = overrideheaderBox.Checked;
ytextbox.Enabled = overrideheaderBox.Checked;
dxbox.Enabled = overrideheaderBox.Checked;
}
// MJ 04/04/05
void WriteSedFile(string posnote)
{
int x,y;
double sumVsusp, sumV1susp, sumV2susp;
double sumTsusp, sumT1susp, sumT2susp;
double sumdV;
sumdV = 0.0;
sumVsusp = 0.0;
sumV1susp = 0.0;
sumV2susp = 0.0;
sumTsusp = 0.0;
sumT1susp = 0.0;
sumT2susp = 0.0;
for (y=1; y<= ymax; y++)
{
for (x=1; x<=xmax; x++)
{
if (elev[x,y] > -9998)
{
sumdV += (init_elevs[x,y]-elev[x,y]);
sumVsusp += Vsusptot[x,y];
sumTsusp += tempsusptot[x,y];
for (int p=0; p<=(TRACERS-1); p++)
{
sumV1susp += Vsusp[x,y,1,p];
sumV2susp += Vsusp[x,y,2,p];
sumT1susp += tempsusp[x,y,1,p];
sumT2susp += tempsusp[x,y,2,p];
}
}
}
}
sumdV = sumdV * (DX*DX);
string output = string.Format("{0:G}",counter);
output = output + string.Format(" {0:F6}",cycle/1440);
output = output + " " + posnote;
output = output + string.Format(" {0:F6}",sumdV);
output = output + string.Format(" {0:F6}",sumVsusp);
output = output + string.Format(" {0:F6}",sumV1susp);
output = output + string.Format(" {0:F6}",sumV2susp);
output = output + string.Format(" {0:F6}",sumTsusp);
output = output + string.Format(" {0:F6}",sumT1susp);
output = output + string.Format(" {0:F6}",sumT2susp);
string EXCHANGE_FILE = "sedexchangeA.txt";
StreamWriter sw = File.AppendText(EXCHANGE_FILE);
sw.WriteLine(output);
sw.Close();
}
private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
{
}
private void bedslope_box_CheckedChanged(object sender, System.EventArgs e)
{
if(bedslope_box.Checked==true){
wslope_box.Checked=false;
veltaubox.Checked=false;
}
}
private void wslope_box_CheckedChanged(object sender, System.EventArgs e)
{
if (wslope_box.Checked == true)
{
bedslope_box.Checked = false;
veltaubox.Checked = false;
}
}
private void oldlateral_CheckedChanged(object sender, System.EventArgs e)
{
if(oldlateral.Checked==true)newlateral.Checked=false;
}
private void newlateral_CheckedChanged(object sender, System.EventArgs e)
{
if(newlateral.Checked==true)oldlateral.Checked=false;
}
private void label54_Click(object sender, System.EventArgs e)
{
}
private void button5_Click(object sender, System.EventArgs e)
{
Form1.ActiveForm.Show();
}
private void button5_Click_1(object sender, System.EventArgs e)
{
init_route(TRUE,init_discharge, baseflow);
time_factor=0.0000000001;
}
private void statusBar1_PanelClick(object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e)
{
}
private void veltaubox_CheckedChanged(object sender, EventArgs e)
{
if (veltaubox.Checked == true)
{
wslope_box.Checked = false;
bedslope_box.Checked = false;
}
}
}
}