Repository navigation
Expand file tree
/
Copy pathtext.c
More file actions
119 lines (112 loc) · 4.77 KB
/
Copy pathtext.c
File metadata and controls
119 lines (112 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// file: text.c
// vim:fileencoding=utf-8:ft=c:tabstop=2
//
// Copyright © 2025 R.F. Smith <rsmith@xs4all.nl>
// SPDX-License-Identifier: MIT
// Created: 2025-08-09 22:26:21 +0200
// Last modified: 2026-06-02T16:44:35+0200
#include "core.h"
#include "version.h"
#include "setup.h"
#include <assert.h>
#include <math.h>
static void engprop(Laminate *pl, FILE *outfile);
static void matrices(Laminate *pl, FILE *outfile);
void text_fea(Laminate *pl, FILE *outfile);
void text_out(Laminate *pl, Options opts)
{
assert(pl != 0);
fputs("Generated by "LONG_VERSION"\n", opts.outfile);
fprintf(opts.outfile, "laminate: %s\n", sv8cstring(pl->name));
fprintf(opts.outfile, "thickness: %.2f mm, density: %4.2f g/cm³\n",
pl->thickness, pl->ρ);
fprintf(opts.outfile, "fiber volume fraction: %4.1f%%, ", 100 * pl->vf);
fprintf(opts.outfile, "fiber weight fraction: %4.1f%%\n", 100 * pl->wf);
fprintf(opts.outfile, "laminate weight: %.0f g/m², ", pl->fiber_weight + pl->resin_weight);
fprintf(opts.outfile, "resin consumption: %.0f g/m²\n", pl->resin_weight);
fprintf(opts.outfile, "num weight angle vf fiber\n");
fprintf(opts.outfile, " [g/m²] [°] [%%]\n");
for (int32_t k = 0; k < pl->nlayers; k++) {
Lamina *la = pl->layers + k;
if (la->comment.data && la->comment.len) {
fwrite(la->comment.data, 1, la->comment.len, opts.outfile);
putc('\n', opts.outfile);
} else if (la->symm) {
fputs("----- symmetry line -----\n", opts.outfile);
}
fprintf(opts.outfile, "%3d %6g %5g %4.3g ", k + 1, la->fiber_weight, 180 * la->angle / M_PI, 100 * la->vf);
fprintf(opts.outfile, "%s\n", sv8cstring(la->f.name));
}
if (opts.eng) {
engprop(pl, opts.outfile);
}
if (opts.matrix) {
matrices(pl, opts.outfile);
}
if (opts.fea) {
text_fea(pl, opts.outfile);
}
fputs("\n", opts.outfile);
fflush(opts.outfile);
}
void engprop(Laminate *pl, FILE *outfile)
{
fputs("In-plane engineering properties:\n", outfile);
fprintf(outfile, "E_x = %.0f MPa, E_y = %.0f MPa, E_z = %.0f MPa\n",
pl->Ex, pl->Ey, pl->Ez);
fprintf(outfile, "G_xy = %.0f MPa, G_xz = %.0f MPa, G_yz = %.0f MPa\n",
pl->Gxy, pl->Gxz, pl->Gyz);
fprintf(outfile, "ν_xy = %7.5f\n", pl->νxy);
fprintf(outfile, "α_x = %9.4g K⁻¹, α_y = %9.4g K⁻¹\n", pl->αx, pl->αy);
fputs("Engineering properties derived from 3D stiffness matrix:\n", outfile);
fprintf(outfile, "E_x = %.0f MPa, E_y = %.0f MPa, E_z = %.0f MPa\n",
pl->tEx, pl->tEy, pl->tEz);
fprintf(outfile, "G_xy = %.0f MPa, G_xz = %.0f MPa, G_yz = %.0f MPa\n",
pl->tGxy, pl->tGxz, pl->tGyz);
fprintf(outfile, "ν_xy = %.3f, ν_xz = %.3f, ν_yz = %.3f\n", pl->tνxy, pl->tνxz, pl->tνyz);
}
void matrices(Laminate *pl, FILE *outfile)
{
fputs("In-plane stiffness (ABD) matrix:\n", outfile);
for (int32_t r = 0; r < 6; r++) {
fprintf(outfile, "|% -10.4g % -10.4g % -10.4g % -10.4g % -10.4g % -10.4g |\n",
pl->ABD[r][0], pl->ABD[r][1], pl->ABD[r][2],
pl->ABD[r][3], pl->ABD[r][4], pl->ABD[r][5]);
}
fputs("Transverse (H) stiffness matrix:\n", outfile);
fprintf(outfile, "|% -10.4g % -10.4g |\n", pl->H[0][0], pl->H[0][1]);
fprintf(outfile, "|% -10.4g % -10.4g |\n", pl->H[1][0], pl->H[1][1]);
fputs("3D stiffness tensor [C], contracted notation:\n", outfile);
fputs("(indices for stress/strain are in the order 11, 22, 33, 23, 13, 12)\n", outfile);
for (int32_t r = 0; r < 6; r++) {
fprintf(outfile, "|% -10.4g % -10.4g % -10.4g % -10.4g % -10.4g % -10.4g |\n",
pl->C[r][0], pl->C[r][1], pl->C[r][2],
pl->C[r][3], pl->C[r][4], pl->C[r][5]);
}
}
void text_fea(Laminate *pl, FILE *outfile)
{
fputs("** Material data for CalculiX / Abaqus (SI units):\n", outfile);
double D[6][6] = {0};
toabaqusi(pl->C, D);
fprintf(outfile, "*MATERIAL,NAME=%s\n", sv8cstring(pl->name));
if (isortho(pl->C)) {
fputs("*ELASTIC,TYPE=ORTHO\n", outfile);
fprintf(outfile, "%.4g,%.4g,%.4g,", D[0][0], D[0][1], D[1][1]);
fprintf(outfile, "%.4g,%.4g,%.4g,", D[0][2], D[1][2], D[2][2]);
fprintf(outfile, "%.4g,%.4g,\n", D[3][3], D[4][4]);
fprintf(outfile, "%.4g,293\n", D[5][5]);
} else {
fputs("*ELASTIC,TYPE=ANISO\n", outfile);
fprintf(outfile, "%.4g,%.4g,%.4g,", D[0][0], D[0][1], D[1][1]);
fprintf(outfile, "%.4g,%.4g,%.4g,", D[0][2], D[1][2], D[2][2]);
fprintf(outfile, "%.4g,%.4g,\n", D[0][3], D[1][3]);
fprintf(outfile, "%.4g,%.4g,%.4g,", D[2][3], D[3][3], D[0][4]);
fprintf(outfile, "%.4g,%.4g,%.4g,", D[1][4], D[2][4], D[3][4]);
fprintf(outfile, "%.4g,%.4g,\n", D[4][4], D[0][5]);
fprintf(outfile, "%.4g,%.4g,%.4g,", D[1][5], D[2][5], D[3][5]);
fprintf(outfile, "%.4g,%.4g,293\n", D[4][5], D[5][5]);
}
fputs("*DENSITY\n", outfile);
fprintf(outfile, "%.0f\n", pl->ρ * 1000);
}