@
<<global.h>>=
+#ifndef GLOBAL_H
+#define GLOBAL_H
<<environment definition>>
<<one dimensional function definition>>
<<create/destroy definitions>>
<<model globals>>
+#endif /* GLOBAL_H */
@
+Where the [[GLOBAL_H]] defines are protecting [[global.h]] from being
+included multiple times.
\section{Simulation functions}
We implement this parsing in [[parse.c]], define the interface in [[parse.h]], and the the unit testing in [[check_parse.c]].
<<parse.h>>=
+#ifndef PARSE
+#define PARSE
<<license comment>>
<<parse definitions>>
<<parse declarations>>
+#endif /* PARSE */
@
<<parse module makefile lines>>=
<<definitions>>
<<globals>>
<<check globals>>
+<<check relative error>>
<<functions>>
<<test suite>>
<<main check program>>
@
<<worm-like chain tests>>=
+extern double wlc(double x, double T, double p, double L);
START_TEST(test_wlc_at_zero)
{
- double T=1.0, L=1.0, p=0.1, x=0.0;
- fail_unless(wlc(x, T, p, L)==0, NULL);
+ double T=1.0, L=1.0, p=0.1, x=0.0, lim=1e-30;
+ fail_unless(abs(wlc(x, T, p, L)) < lim, \
+ "abs(wlc(x=%g,T=%g,p=%g,L=%g)) = %g >= %g",
+ x, T, p, L, abs(wlc(x, T, p, L)), lim);
}
END_TEST
[[check_tension_balance.c]]
<<tension-balance.h>>=
+#ifndef TENSION_BALANCE_H
+#define TENSION_BALANCE_H
<<license comment>>
<<tension balance function declaration>>
+#endif /* TENSION_BALANCE_H */
@
<<tension balance functions>>=
<<tension balance function tests>>=
START_TEST(test_double_hooke)
{
- double k1=5, k2=4, x=3, last_x=2.0, F, Fe, x1e, x2e;
+ double k1=5, k2=4, x=3, last_x=-1.0, F, Fe, x1e, x2e;
one_dim_fn_t *handlers[] = {&hooke, &hooke};
void *data[] = {&k1, &k2};
F = tension_balance(2, handlers, data, last_x, x);
}
END_TEST
@
+TODO: test [[tension_balance()]] with another balance after the [[x_of_xo_data]] initializing balance we ran above.
<<tension balance function test case defs>>=
TCase *tc_tbfunc = tcase_create("tension balance function");
The interface is defined in [[list.h]], the implementation in [[list.c]], and the unit testing in [[check_list.c]]
<<list.h>>=
+#ifndef LIST_H
+#define LIST_H
<<license comment>>
<<list definitions>>
<<list declarations>>
+#endif /* LIST_H */
@
<<list declarations>>=
The interface is defined in [[string_eval.h]], the implementation in [[string_eval.c]], and the unit testing in [[check_string_eval.c]].
<<string-eval.h>>=
+#ifndef STRING_EVAL_H
+#define STRING_EVAL_H
<<license comment>>
<<string eval setup declaration>>
<<string eval function declaration>>
<<string eval teardown declaration>>
+#endif /* STRING_EVAL_H */
@
<<string eval module makefile lines>>=
The number of evaluation calls could be drastically reduced, however, by implementing an $x(x_0)$ lookup table.
<<accel-k.h>>=
+#ifndef ACCEL_K_H
+#define ACCEL_K_H
double accel_k(k_func_t *k, double F, environment_t *env, void *params);
void free_accels();
+#endif /* ACCEL_K_H */
@
<<accel k module makefile lines>>=
The interface is defined in [[tension_model.h]], the implementation in [[tension_model.c]], the unit testing in [[check_k_model.c]], and some other tidbits in [[tension_model_utils.c]].
<<tension-model.h>>=
+#ifndef TENSION_MODEL_H
+#define TENSION_MODEL_H
<<license comment>>
<<tension handler types>>
<<constant tension model declarations>>
<<freely-jointed chain tension model declarations>>
<<find tension definitions>>
<<tension model global declarations>>
+#endif /* TENSION_MODEL_H */
@
<<tension model module makefile lines>>=
which I don't like as much.
<<k-model.h>>=
+#ifndef K_MODEL_H
+#define K_MODEL_H
<<license comment>>
<<k func definition>>
<<null k declarations>>
<<bell k declarations>>
<<kramers k declarations>>
<<kramers integ k declarations>>
+#endif /* K_MODEL_H */
@
<<k model module makefile lines>>=