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 #include <utils/utils.h>
00024 #include <sed/sed_sedflux.h>
00025
00035
00036 GQuark
00037 compact_error_quark( void )
00038 {
00039 return g_quark_from_static_string( "compact-error-quark" );
00040 }
00041
00067 int compact( Sed_column s )
00068 {
00069 double *load_eff;
00070 double hydro_static;
00071 gssize n_grains = sed_sediment_env_n_types();
00072
00073
00074
00075 if ( sed_column_len(s) < 2 )
00076 return 0;
00077
00078 load_eff = eh_new0( double , sed_column_len(s) );
00079 hydro_static = sed_column_water_pressure( s );
00080
00081
00082 {
00083 gssize i;
00084 double p;
00085 double* load = sed_column_load( s , 0 , -1 , NULL );
00086
00087 for (i=sed_column_len(s)-1; i>=0; --i)
00088 {
00089 p = sed_cell_pressure( sed_column_nth_cell( s , i ) );
00090
00091 load_eff[i] = load[i] - p;
00092
00093 if ( load_eff[i] < 0 )
00094 load_eff[i] = 0.;
00095 }
00096
00097 eh_free( load );
00098 }
00099
00100
00101 {
00102 gssize i, n;
00103 Sed_cell this_cell;
00104 double t_new;
00105 double* c = sed_sediment_property( NULL , &sed_type_compressibility );
00106 double* rho_grain = sed_sediment_property( NULL , &sed_type_rho_grain );
00107 double* rho_max = sed_sediment_property( NULL , &sed_type_rho_max );
00108 double* rho = sed_sediment_property( NULL , &sed_type_rho_sat );
00109 double rho_new;
00110 double t_0;
00111
00112 for (i=sed_column_len(s)-1; i>=0 ; i--)
00113 {
00114 this_cell = sed_column_nth_cell( s , i );
00115 for ( n=0 , t_new=0. ; n<n_grains ; n++ )
00116 {
00117 t_0 = sed_cell_sediment_volume(this_cell)*sed_cell_fraction(this_cell,n);
00118 rho_new = rho_max[n] + (rho[n]-rho_max[n]) / exp(c[n]*load_eff[i]);
00119
00120 t_new += t_0*(rho_grain[n]-sed_rho_sea_water())/(rho_new-sed_rho_sea_water());
00121
00122 if ( t_new< 0 )
00123 {
00124 t_new = 0;
00125 eh_require_not_reached();
00126 }
00127
00128 }
00129
00130
00131
00132 if ( t_new < sed_cell_size(this_cell) )
00133 sed_column_compact_cell(s,i,t_new);
00134 }
00135
00136 eh_free( c );
00137 eh_free( rho_max );
00138 eh_free( rho_grain );
00139 eh_free( rho );
00140 }
00141
00142 eh_free(load_eff);
00143
00144 return 0;
00145 }
00146