/test/relax-exper.c

https://github.com/mirrorscotty/material-data · C · 84 lines · 69 code · 15 blank · 0 comment · 4 complexity · 36723d3541ad4872535fb7e67434d453 MD5 · raw file

  1. #include "material-data.h"
  2. #include "matrix.h"
  3. #include <complex.h>
  4. #include <math.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. double strain(double t)
  8. {
  9. double str=.01, t0=10;
  10. if(t>t0)
  11. return str;
  12. else
  13. return 0;
  14. }
  15. int main(int argc, char *argv[])
  16. {
  17. maxwell *m;
  18. vector *t, *Ecummings, *Elaura, *Egina;
  19. matrix *out;
  20. double ti, tj, Ecummingsi, Elaurai, Eginai, dstrain;
  21. int i, j, n=1000;
  22. double T,
  23. M,
  24. P=.2e6, /* Applied force (Pa) */
  25. tf=100, /* Final time */
  26. dt;
  27. char *outfile;
  28. if(argc < 3) {
  29. puts("Usage: relax-exper <T> <M>");
  30. puts("<T>\tTemperature\t\t(K)");
  31. puts("<M>\tMoisture Content\t(kg/kg db)");
  32. exit(0);
  33. }
  34. T = atof(argv[1]);
  35. M = atof(argv[2]);
  36. m = CreateMaxwell();
  37. t = linspaceV(0, tf, n);
  38. dt = valV(t, 1)-valV(t, 0);
  39. Ecummings = CreateVector(n);
  40. Elaura = CreateVector(n);
  41. Egina = CreateVector(n);
  42. for(i=0; i<n; i++) {
  43. ti = valV(t, i);
  44. Ecummingsi = 0;//MaxwellRelax(m, ti, T, M)*strain(ti);
  45. Elaurai = 0;//MaxwellRelaxLaura(ti, T, M)*strain(ti);
  46. Eginai = 0;//LGinaRelax(ti, T, M, P)*strain(ti);
  47. for(j=0; j<i; j++) {
  48. tj = valV(t, j);
  49. dstrain = (strain(tj+dt)-strain(tj))/dt;
  50. Ecummingsi += MaxwellRelax(m, ti, T, M)*dstrain*dt;
  51. Elaurai += MaxwellRelaxLaura(ti, T, M)*dstrain*dt;
  52. Eginai += LGinaRelax(ti, T, M, P)*dstrain*dt;
  53. }
  54. setvalV(Ecummings, i, Ecummingsi);
  55. setvalV(Elaura, i, Elaurai);
  56. setvalV(Egina, i, Eginai);
  57. }
  58. out = CatColVector(4, t, Ecummings, Elaura, Egina);
  59. outfile = (char*) calloc(30, sizeof(char));
  60. sprintf(outfile, "relax-%g-%g.csv", T, M);
  61. mtxprntfilehdr(out, outfile, "Time,Cummings,Rozzi,Bressani\n");
  62. DestroyMaxwell(m);
  63. DestroyVector(t);
  64. DestroyVector(Ecummings);
  65. DestroyVector(Elaura);
  66. DestroyVector(Egina);
  67. DestroyMatrix(out);
  68. return;
  69. }