From 403c2e5eece04bf8c6409b391ec4fcc722ab0e91 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 11 Nov 2008 15:59:10 -0500 Subject: [PATCH] Added Fmax and Xmax options to tension_model_utils Also added Fmax/Xmax/xmax_special/etc current value outputs to tension_model_utils and k_model_utils. --- src/sawsim.nw | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/sawsim.nw b/src/sawsim.nw index 202fb10..a748e88 100644 --- a/src/sawsim.nw +++ b/src/sawsim.nw @@ -3719,7 +3719,9 @@ int main(int argc, char **argv) tension_handler_data_t tdata; int num_param_args; /* for INIT_MODEL() */ char **param_args; /* for INIT_MODEL() */ - get_options(argc, argv, &env, NUM_TENSION_MODELS, tension_models, &model, &flags); + double Fmax,Xmax; + get_options(argc, argv, &env, NUM_TENSION_MODELS, tension_models, &model, + &Fmax, &Xmax, &flags); setup(); if (flags & VFLAG) { printf("#initializing model %s with parameters %s\n", model->name, model->params); @@ -3734,12 +3736,14 @@ int main(int argc, char **argv) exit(0); } { - double dx=1e-10, x=0, F=0; + int i,N=200; + double x=0, F=0; printf("#F (N)\tk (%% pop. per s)\n"); - while (F >= 0 && F < 1e5 && x < 1e-6) { + for (i=0; i<=N; i++) { + x = Xmax*i/(double)N; F = (*model->handler)(x, &tdata); + if (F < 0 || F > Fmax) break; printf("%g\t%g\n", x, F); - x += dx; } } params = pop(&tdata.group); @@ -3779,7 +3783,7 @@ int main(int argc, char **argv) void help(char *prog_name, environment_t *env, int n_tension_models, tension_model_getopt_t *tension_models, - int tension_model) + int tension_model, double Fmax, double Xmax) { int i, j; printf("usage: %s [options]\n", prog_name); @@ -3798,6 +3802,8 @@ void help(char *prog_name, printf(" #Distance (x)\tForce (N)\n"); printf(" 123.456\t7.89\n"); printf(" ...\n"); + printf("-F\tSet the maximum F value for the standard mode F(x) output (currently %g)\n", Fmax); + printf("-X\tSet the maximum x value for the standart mode F(x) output (currently %g)\n", Xmax); printf("-V\tChange output to verbose mode\n"); printf("-h\tPrint this help and exit\n"); printf("\n"); @@ -3814,11 +3820,11 @@ void help(char *prog_name, <>= void get_options(int argc, char **argv, environment_t *env, int n_tension_models, tension_model_getopt_t *tension_models, - tension_model_getopt_t **model, + tension_model_getopt_t **model, double *Fmax, double *Xmax, unsigned int *flags) { char *prog_name = NULL; - char c, options[] = "T:C:m:a:Vh"; + char c, options[] = "T:C:m:a:F:X:Vh"; int tension_model=0, num_strings; extern char *optarg; extern int optind, optopt, opterr; @@ -3829,6 +3835,8 @@ void get_options(int argc, char **argv, environment_t *env, prog_name = argv[0]; env->T = 300.0; /* K */ + *Fmax = 1e5; + *Xmax = 1e-6; *flags = 0; *model = tension_models; @@ -3843,12 +3851,14 @@ void get_options(int argc, char **argv, environment_t *env, case 'a': tension_models[tension_model].params = optarg; break; - case 'V': *flags |= VFLAG; break; + case 'F': *Fmax = atof(optarg); break; + case 'X': *Xmax = atof(optarg); break; + case 'V': *flags |= VFLAG; break; case '?': fprintf(stderr, "unrecognized option '%c'\n", optopt); /* fall through to default case */ default: - help(prog_name, env, n_tension_models, tension_models, tension_model); + help(prog_name, env, n_tension_models, tension_models, tension_model, *Fmax, *Xmax); exit(1); } } @@ -5000,7 +5010,7 @@ enum mode_t {M_K_OF_F, M_SPECIAL}; void help(char *prog_name, environment_t *env, int n_k_models, k_model_getopt_t *k_models, - int k_model) + int k_model, double Fmax, double special_xmin, double special_xmax) { int i, j; printf("usage: %s [options]\n", prog_name); @@ -5026,9 +5036,9 @@ void help(char *prog_name, printf(" ...\n"); printf("-m\tChange output to standard mode\n"); printf("-M\tChange output to special mode\n"); - printf("-F\tSet the maximum F value for the standard mode k(F) output\n"); - printf("-x\tSet the minimum x value for the special mode E(x) output\n"); - printf("-X\tSet the maximum x value for the special mode E(x) output\n"); + printf("-F\tSet the maximum F value for the standard mode k(F) output (currently %g)\n", Fmax); + printf("-x\tSet the minimum x value for the special mode E(x) output (currently %g)\n", special_xmin); + printf("-X\tSet the maximum x value for the special mode E(x) output (currently %g)\n", special_xmax); printf("-V\tChange output to verbose mode\n"); printf("-h\tPrint this help and exit\n"); printf("\n"); @@ -5089,7 +5099,7 @@ void get_options(int argc, char **argv, environment_t *env, fprintf(stderr, "unrecognized option '%c'\n", optopt); /* fall through to default case */ default: - help(prog_name, env, n_k_models, k_models, k_model); + help(prog_name, env, n_k_models, k_models, k_model, *Fmax, *special_xmin, *special_xmax); exit(1); } } -- 2.26.2