simulation.h (4844B)
1 #ifndef SIMULATION_ 2 #define SIMULATION_ 3 4 #include "arrays.h" 5 6 #define PI 3.14159265358979323846 7 #define DEG2RAD(x) (x*PI/180.0) 8 9 /* Simulation settings */ 10 struct simulation { 11 12 /* simulation name to use for output files */ 13 char name[100]; 14 15 /* gravitational acceleration magnitude [m/s^2] */ 16 double G; 17 18 /* wall parameters */ 19 double P_wall; // normal stress from top wall [Pa] 20 21 /* optionally fix top shear velocity to this value [m/s] */ 22 double v_x_fix; 23 24 /* optionally fix top shear velocity to this value [m/s] */ 25 double v_x_limit; 26 27 /* bottom velocity along x [m/s] */ 28 double v_x_bot; 29 30 /* stress ratio at top wall */ 31 double mu_wall; 32 33 /* nonlocal amplitude [-] */ 34 double A; 35 36 /* rate dependence beyond yield [-] */ 37 double b; 38 39 /* bulk and critical state static yield friction coefficient [-] */ 40 double mu_s; 41 42 /* material cohesion [Pa] */ 43 double C; 44 45 /* representative grain size [m] */ 46 double d; 47 48 /* grain material density [kg/m^3] */ 49 double rho_s; 50 51 /* smallest observable porosity [-] (I -> 0) */ 52 double phi_min; 53 54 /* porosity when I=0 [-] */ 55 double phi_max; 56 57 /* dilatancy constant [-] */ 58 double K; 59 60 /* nodes along z */ 61 int nz; 62 63 /* origo of axis [m] */ 64 double origo_z; 65 66 /* length of domain [m] */ 67 double L_z; 68 69 /* array of cell coordinates */ 70 double* z; 71 72 /* cell spacing [m] */ 73 double dz; 74 75 /* current time [s] */ 76 double t; 77 78 /* end time [s] */ 79 double t_end; 80 81 /* time step length [s] */ 82 double dt; 83 84 /* interval between output files [s] */ 85 double file_dt; 86 87 /* output file number */ 88 int n_file; 89 90 /* Fluid parameters */ 91 int fluid; /* flag to switch fluid on (1) or off (0) */ 92 double p_f_top; /* fluid pressure at the top [Pa] */ 93 double p_f_mod_ampl; /* amplitude of fluid pressure variations [Pa] */ 94 double p_f_mod_freq; /* frequency of fluid pressure variations [s^-1] */ 95 double p_f_mod_phase; /* phase of fluid pressure variations [s^-1] */ 96 double p_f_mod_pulse_time; /* single pressure pulse at this time [s] */ 97 int p_f_mod_pulse_shape; /* waveform for fluid-pressure pulse */ 98 double beta_f; /* adiabatic fluid compressibility [Pa^-1] */ 99 double mu_f; /* fluid dynamic viscosity [Pa*s] */ 100 double rho_f; /* fluid density [kg/m^3] */ 101 102 /* arrays */ 103 double* mu; /* static yield friction [-] */ 104 double* mu_c; /* critical-state static yield friction [-] */ 105 double* tau; /* shear stess [Pa] */ 106 double* tau_c; /* critical-state shear stress [Pa] */ 107 double* sigma_n_eff; /* effective normal pressure [Pa] */ 108 double* sigma_n; /* normal stress [Pa] */ 109 double* p_f_ghost; /* fluid pressure [Pa] */ 110 double* k; /* hydraulic permeability [m^2] */ 111 double* phi; /* porosity [-] */ 112 double* phi_c; /* critical-state porosity [-] */ 113 double* xi; /* cooperativity length */ 114 double* gamma_dot_p; /* plastic shear strain rate [1/s] */ 115 double* v_x; /* shear velocity [m/s] */ 116 double* g_ghost; /* fluidity with ghost nodes */ 117 double* I; /* inertia number [-] */ 118 double* tan_dilatancy_angle; /* tan(dilatancy_angle) [-] */ 119 }; 120 121 122 void prepare_arrays(struct simulation* sim); 123 void free_arrays(struct simulation* sim); 124 125 void check_simulation_parameters(const struct simulation* sim); 126 127 void lithostatic_pressure_distribution(struct simulation* sim); 128 129 void compute_inertia_number(struct simulation* sim); 130 void compute_critical_state_porosity(struct simulation* sim); 131 void compute_critical_state_friction(struct simulation* sim); 132 void compute_critical_state_shear_stress(struct simulation* sim); 133 void compute_shear_stress(struct simulation* sim); 134 void compute_tan_dilatancy_angle(struct simulation* sim); 135 void compute_porosity_change(struct simulation* sim); 136 void compute_permeability(struct simulation* sim); 137 138 void set_bc_neumann(double* g_ghost, 139 const int nz, 140 const int boundary, 141 const double df, 142 const double dx); 143 144 void set_bc_dirichlet(double* g_ghost, 145 const int nz, 146 const int boundary, 147 const double value); 148 149 void compute_cooperativity_length(struct simulation* sim); 150 void compute_shear_strain_rate_plastic(struct simulation* sim); 151 void compute_shear_velocity(struct simulation* sim); 152 void compute_effective_stress(struct simulation* sim); 153 void compute_friction(struct simulation* sim); 154 155 int implicit_1d_jacobian_poisson_solver(struct simulation* sim, 156 const int max_iter, 157 const double rel_tol); 158 159 void write_output_file(struct simulation* sim, const int normalize); 160 void print_dry_output(FILE* fp, struct simulation* sim, const int normalize); 161 void print_wet_output(FILE* fp, struct simulation* sim, const int normalize); 162 163 #endif