00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022 #include <math.h>
00023
00024 #include <glib.h>
00025 #include <utils/utils.h>
00026 #include "flow.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 #define SED_RATE_DEFAULT (.005)
00074 #define DEPTH_DEFAULT (1500.)
00075 #define PSI_BASE_DEFAULT (80.)
00076 #define DZ_DEFAULT (25.)
00077 #define DX_DEFAULT (25.)
00078 #define DT_DEFAULT (48000.)
00079 #define END_TIME_DEFAULT (1280000.)
00080 #define PSI_MIN_DEFAULT (10.)
00081 #define N_DEFAULT (5)
00082 #define VERBOSE_DEFAULT (FALSE)
00083
00084 void print_profile_2d( double t , double **psi , int n );
00085
00086 static char *help_msg[] = {
00087 " flow - sovle the 1d consolidation equation. ",
00088 " ",
00089 " options: ",
00090 " r : sedimentation rate (m/s) ",
00091 " d : initial depth of the sediment (m) ",
00092 " u0 : excess porewater pressure at the bsae of the model ",
00093 " umin : excess porewater pressure of surface sediment ",
00094 " dz : vertical resolution of the model (m) ",
00095 " dt : time resolution of the model (s) ",
00096 " end : length of the model (s) ",
00097 " ",
00098 NULL };
00099
00100 #include <stdlib.h>
00101
00102 int main( int argc , char *argv[] )
00103 {
00104 double *sed_rate_vec;
00105 double sed_rate;
00106 double depth;
00107 double psi_base;
00108 double psi_min;
00109 double dx;
00110 double dz;
00111 double dt;
00112 double dt_init;
00113 double end_time;
00114 gboolean verbose;
00115 int i, j, n;
00116 double t;
00117 double **psi;
00118 double **kx, **kz, **c;
00119 Eh_args *args;
00120
00121 args = eh_opts_init( argc , argv );
00122 if ( eh_check_opts( args , NULL , NULL , help_msg )!=0 )
00123 eh_exit(-1);
00124
00125 sed_rate = eh_get_opt_dbl ( args , "r" , SED_RATE_DEFAULT );
00126 depth = eh_get_opt_dbl ( args , "d" , DEPTH_DEFAULT );
00127 psi_base = eh_get_opt_dbl ( args , "u0" , PSI_BASE_DEFAULT );
00128 psi_min = eh_get_opt_dbl ( args , "umin" , PSI_MIN_DEFAULT );
00129 dz = eh_get_opt_dbl ( args , "dz" , DZ_DEFAULT );
00130 n = eh_get_opt_int ( args , "n" , N_DEFAULT );
00131 dx = eh_get_opt_dbl ( args , "dx" , DZ_DEFAULT );
00132 dt_init = eh_get_opt_dbl ( args , "dt" , DT_DEFAULT );
00133 end_time = eh_get_opt_dbl ( args , "end" , END_TIME_DEFAULT );
00134 verbose = eh_get_opt_bool( args , "v" , VERBOSE_DEFAULT );
00135
00136 if ( verbose )
00137 {
00138 eh_print_opt( args , "r" );
00139 eh_print_opt( args , "d" );
00140 eh_print_opt( args , "u0" );
00141 eh_print_opt( args , "umin" );
00142 eh_print_opt( args , "dz" );
00143 eh_print_opt( args , "dt" );
00144 eh_print_opt( args , "end" );
00145 eh_print_opt( args , "n" );
00146 }
00147
00148
00149 n = pow(2,n)+1;
00150
00151 dz = depth/(n-1);
00152
00153
00154 psi = allocate_2d( n );
00155 kx = allocate_2d( n );
00156 kz = allocate_2d( n );
00157 c = allocate_2d( n );
00158
00159 for ( i=0 ; i<n ; i++ )
00160 {
00161 for ( j=0 ; j<n ; j++ )
00162 {
00163 psi[i][j] = 1;
00164 kx[i][j] = 1;
00165 kz[i][j] = 1;
00166 c[i][j] = 1.;
00167 if ( j>n/4 && j<n/2 )
00168 {
00169 kx[i][j] = .1;
00170 kz[i][j] = .1;
00171 }
00172 }
00173 }
00174
00175 sed_rate_vec = eh_linspace( 0 , sed_rate , n );
00176
00177 for ( j=0 ; j<n ; j++ )
00178 {
00179 psi[j][n-1] = psi_min;
00180 sed_rate_vec[j] = 0;
00181 }
00182
00183
00184
00185
00186 print_profile_2d( t , psi , n );
00187
00188 for ( t=0 ; t<end_time ; t+=dt)
00189 {
00190
00191 dt = dt_init;
00192
00193 solve_excess_pore_pressure_mg_2d( psi , kx , kz , c , n , dx , dz , dt , sed_rate_vec );
00194
00195
00196 print_profile_2d( t+dt , psi , n );
00197
00198 }
00199
00200
00201
00202 return 0;
00203 }
00204
00205
00206 void print_profile_2d( double t , double **psi , int n )
00207 {
00208 int i, j;
00209 fprintf( stdout , "%f ", t );
00210 for ( i=0 ; i<n ; i++ )
00211 for ( j=0 ; j<n ; j++ )
00212 fprintf( stdout , ", %f ", psi[i][j] );
00213 fprintf( stdout , "\n" );
00214 }
00215