New parameter: starting_time

This commit is contained in:
Ian Jauslin 2022-05-27 17:06:38 -04:00
parent 0cdb914b57
commit 6113c85189
3 changed files with 17 additions and 6 deletions

View File

@ -24,6 +24,7 @@ typedef struct nstrophy_parameters {
double L; double L;
unsigned int print_freq; unsigned int print_freq;
int seed; int seed;
unsigned int starting_time;
} nstrophy_parameters; } nstrophy_parameters;
// usage message // usage message
@ -119,10 +120,10 @@ int main (
// run command // run command
if (command==COMMAND_UK){ if (command==COMMAND_UK){
uk(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, parameters.print_freq, nthreads, savefile); uk(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, parameters.print_freq, parameters.starting_time, nthreads, savefile);
} }
else if(command==COMMAND_EEA){ else if(command==COMMAND_EEA){
eea(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, parameters.print_freq, nthreads, savefile); eea(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, parameters.print_freq, parameters.starting_time, nthreads, savefile);
} }
else if(command==COMMAND_QUIET){ else if(command==COMMAND_QUIET){
quiet(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, nthreads, savefile); quiet(parameters.K1, parameters.K2, parameters.N1, parameters.N2, parameters.nsteps, parameters.nu, parameters.delta, parameters.L, u0, g, nthreads, savefile);
@ -345,6 +346,7 @@ int read_params(
parameters->L=2*M_PI; parameters->L=2*M_PI;
parameters->nsteps=10000000; parameters->nsteps=10000000;
parameters->print_freq=1000; parameters->print_freq=1000;
parameters->starting_time=0;
parameters->seed=17; parameters->seed=17;
if (param_str!=NULL){ if (param_str!=NULL){
@ -516,6 +518,13 @@ int set_parameter(
return(-1); return(-1);
} }
} }
else if (strcmp(lhs,"starting_time")==0){
ret=sscanf(rhs,"%u",&(parameters->starting_time));
if(ret!=1){
fprintf(stderr, "error: parameter 'starting_time' should be an unsigned integer\n got '%s'\n",rhs);
return(-1);
}
}
else{ else{
fprintf(stderr, "error: unrecognized parameter '%s'\n",lhs); fprintf(stderr, "error: unrecognized parameter '%s'\n",lhs);
return(-1); return(-1);

View File

@ -16,6 +16,7 @@ int uk(
_Complex double* u0, _Complex double* u0,
_Complex double* g, _Complex double* g,
unsigned int print_freq, unsigned int print_freq,
unsigned int starting_time,
unsigned int nthreads, unsigned int nthreads,
FILE* savefile FILE* savefile
){ ){
@ -46,7 +47,7 @@ int uk(
} }
// iterate // iterate
for(t=0;t<nsteps;t++){ for(t=starting_time;t<starting_time+nsteps;t++){
ins_step(u, K1, K2, N1, N2, nu, delta, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3); ins_step(u, K1, K2, N1, N2, nu, delta, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3);
if(t%print_freq==0){ if(t%print_freq==0){
@ -87,6 +88,7 @@ int eea(
_Complex double* u0, _Complex double* u0,
_Complex double* g, _Complex double* g,
unsigned int print_freq, unsigned int print_freq,
unsigned int starting_time,
unsigned int nthreads, unsigned int nthreads,
FILE* savefile FILE* savefile
){ ){
@ -112,7 +114,7 @@ int eea(
avg_en=0; avg_en=0;
// iterate // iterate
for(t=0;t<nsteps;t++){ for(t=starting_time;t<starting_time+nsteps;t++){
ins_step(u, K1, K2, N1, N2, nu, delta, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3); ins_step(u, K1, K2, N1, N2, nu, delta, L, g, fft1, fft2, ifft, tmp1, tmp2, tmp3);
energy=compute_energy(u, K1, K2); energy=compute_energy(u, K1, K2);

View File

@ -13,10 +13,10 @@ typedef struct fft_vects {
} fft_vect; } fft_vect;
// compute u_k // compute u_k
int uk( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, unsigned int print_freq, unsigned int nthreadsl, FILE* savefile); int uk( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, unsigned int print_freq, unsigned int starting_time, unsigned int nthreadsl, FILE* savefile);
// compute energy, enstrophy and alpha // compute energy, enstrophy and alpha
int eea( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, unsigned int print_freq, unsigned int nthreads, FILE* savefile); int eea( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, unsigned int print_freq, unsigned int starting_time, unsigned int nthreads, FILE* savefile);
// compute solution as a function of time, but do not print anything (useful for debugging) // compute solution as a function of time, but do not print anything (useful for debugging)
int quiet( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, unsigned int nthreads, FILE* savefile); int quiet( int K1, int K2, int N1, int N2, unsigned int nsteps, double nu, double delta, double L, _Complex double* u0, _Complex double* g, unsigned int nthreads, FILE* savefile);