@jtgtools/xbeam 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,150 @@
1
+ type SupportKind = 'ROLLER' | 'PINNED' | 'FIXED';
2
+ interface Support {
3
+ kind: SupportKind;
4
+ position: number;
5
+ }
6
+ interface PointLoad {
7
+ /**
8
+ * Force magnitude in N.
9
+ * Upward positive, downward negative.
10
+ */
11
+ magnitude: number;
12
+ position: number;
13
+ }
14
+ interface DistributedLoad {
15
+ /**
16
+ * Linearly varying distributed load intensity q(x) in N/m.
17
+ * Sign convention matches `PointLoad`.
18
+ */
19
+ startMagnitude: number;
20
+ endMagnitude: number;
21
+ startPosition: number;
22
+ endPosition: number;
23
+ }
24
+ interface AppliedMoment {
25
+ /**
26
+ * Concentrated bending moment at a point, in N·m.
27
+ * Positive sagging convention is used internally.
28
+ */
29
+ magnitude: number;
30
+ position: number;
31
+ }
32
+ interface BeamInput {
33
+ length: number;
34
+ modulusOfElasticity: number;
35
+ momentOfInertia: number;
36
+ supports: Support[];
37
+ pointLoads: PointLoad[];
38
+ distributedLoads: DistributedLoad[];
39
+ appliedMoments?: AppliedMoment[];
40
+ }
41
+ interface BeamReactions {
42
+ /**
43
+ * Vertical reaction force per node (size nNodes).
44
+ * Upward positive (same sign convention as point loads).
45
+ */
46
+ vertical: Float64Array;
47
+ /**
48
+ * Reaction moment per node associated with rotation DOF (size nNodes).
49
+ * Non-zero only for `FIXED` supports.
50
+ */
51
+ moment: Float64Array;
52
+ }
53
+ interface BeamResults {
54
+ nodePositions: Float64Array;
55
+ deflections: Float64Array;
56
+ rotations: Float64Array;
57
+ /**
58
+ * Nodal bending moments averaged from element-end curvatures.
59
+ */
60
+ moments: Float64Array;
61
+ /**
62
+ * Nodal shear using right-side semantics V(x+).
63
+ */
64
+ shears: Float64Array;
65
+ reactions: BeamReactions;
66
+ }
67
+ interface XYSeries {
68
+ x: Float64Array;
69
+ y: Float64Array;
70
+ }
71
+ interface BeamDiagrams {
72
+ deflection: XYSeries;
73
+ moment: XYSeries;
74
+ shear: XYSeries;
75
+ }
76
+ interface DiagramOptions {
77
+ pointsPerElement?: number;
78
+ eps?: number;
79
+ includeOutsideEnds?: boolean;
80
+ }
81
+ interface MeshOptions {
82
+ maxElements?: number;
83
+ minElementsPerSegment?: number;
84
+ eps?: number;
85
+ }
86
+ interface Mesh {
87
+ nodes: Float64Array;
88
+ /**
89
+ * Find the closest node index to `x` if within `eps`, otherwise returns -1.
90
+ * This handles cases where user-provided load coordinates have small floating error.
91
+ */
92
+ findNodeIndex: (x: number, eps: number) => number;
93
+ }
94
+ interface LinearSystem {
95
+ bandedK: Float64Array;
96
+ forceVector: Float64Array;
97
+ nodePositions: Float64Array;
98
+ }
99
+ interface BoundaryConditions {
100
+ freeDofs: Int32Array;
101
+ restrainedDofs: Int32Array;
102
+ }
103
+
104
+ interface SolveOutputs {
105
+ displacements: Float64Array;
106
+ reactions: BeamReactions;
107
+ }
108
+ /**
109
+ * Pre-allocated scratch space for repeated solves on the same mesh topology.
110
+ * Create once with `createSolverBuffers(nDof)`, reuse across many solve calls.
111
+ */
112
+ interface SolverBuffers {
113
+ readonly nDof: number;
114
+ compactOf: Int32Array;
115
+ Kff: Float64Array;
116
+ Lband: Float64Array;
117
+ ff: Float64Array;
118
+ y: Float64Array;
119
+ uf: Float64Array;
120
+ u: Float64Array;
121
+ }
122
+ declare function createSolverBuffers(nDof: number): SolverBuffers;
123
+ /**
124
+ * Same as `solveLinearSystem` but uses pre-allocated buffers.
125
+ * All output arrays inside `buffers` are overwritten in place.
126
+ */
127
+ declare function solveLinearSystemBuffered(system: LinearSystem, bc: BoundaryConditions, buffers: SolverBuffers): SolveOutputs;
128
+
129
+ declare function assembleSystem(beam: BeamInput, mesh: Mesh): LinearSystem;
130
+ declare function getBoundaryConditions(beam: BeamInput, mesh: Mesh): BoundaryConditions;
131
+
132
+ declare function generateMesh(beam: BeamInput, options?: MeshOptions): Mesh;
133
+
134
+ /**
135
+ * Solves a static linear Euler-Bernoulli beam model and returns nodal responses
136
+ * (deflection/rotation, moments, shears, and support reactions).
137
+ */
138
+ declare function analyzeBeam(beam: BeamInput, meshOptions?: MeshOptions): BeamResults;
139
+ /**
140
+ * Convenience wrapper that also returns chart-ready diagram series:
141
+ * `deflection`, `moment`, and `shear`.
142
+ *
143
+ * Diagram series include discontinuity-friendly duplicate `x` coordinates.
144
+ */
145
+ declare function analyzeBeamChartReady(beam: BeamInput, meshOptions?: MeshOptions, diagramOptions?: DiagramOptions): {
146
+ results: BeamResults;
147
+ diagrams: BeamDiagrams;
148
+ };
149
+
150
+ export { type AppliedMoment, type BeamDiagrams, type BeamInput, type BeamReactions, type BeamResults, type BoundaryConditions, type DiagramOptions, type DistributedLoad, type LinearSystem, type Mesh, type MeshOptions, type PointLoad, type Support, type SupportKind, type XYSeries, analyzeBeam, analyzeBeamChartReady, assembleSystem, createSolverBuffers, generateMesh, getBoundaryConditions, solveLinearSystemBuffered };
@@ -0,0 +1,150 @@
1
+ type SupportKind = 'ROLLER' | 'PINNED' | 'FIXED';
2
+ interface Support {
3
+ kind: SupportKind;
4
+ position: number;
5
+ }
6
+ interface PointLoad {
7
+ /**
8
+ * Force magnitude in N.
9
+ * Upward positive, downward negative.
10
+ */
11
+ magnitude: number;
12
+ position: number;
13
+ }
14
+ interface DistributedLoad {
15
+ /**
16
+ * Linearly varying distributed load intensity q(x) in N/m.
17
+ * Sign convention matches `PointLoad`.
18
+ */
19
+ startMagnitude: number;
20
+ endMagnitude: number;
21
+ startPosition: number;
22
+ endPosition: number;
23
+ }
24
+ interface AppliedMoment {
25
+ /**
26
+ * Concentrated bending moment at a point, in N·m.
27
+ * Positive sagging convention is used internally.
28
+ */
29
+ magnitude: number;
30
+ position: number;
31
+ }
32
+ interface BeamInput {
33
+ length: number;
34
+ modulusOfElasticity: number;
35
+ momentOfInertia: number;
36
+ supports: Support[];
37
+ pointLoads: PointLoad[];
38
+ distributedLoads: DistributedLoad[];
39
+ appliedMoments?: AppliedMoment[];
40
+ }
41
+ interface BeamReactions {
42
+ /**
43
+ * Vertical reaction force per node (size nNodes).
44
+ * Upward positive (same sign convention as point loads).
45
+ */
46
+ vertical: Float64Array;
47
+ /**
48
+ * Reaction moment per node associated with rotation DOF (size nNodes).
49
+ * Non-zero only for `FIXED` supports.
50
+ */
51
+ moment: Float64Array;
52
+ }
53
+ interface BeamResults {
54
+ nodePositions: Float64Array;
55
+ deflections: Float64Array;
56
+ rotations: Float64Array;
57
+ /**
58
+ * Nodal bending moments averaged from element-end curvatures.
59
+ */
60
+ moments: Float64Array;
61
+ /**
62
+ * Nodal shear using right-side semantics V(x+).
63
+ */
64
+ shears: Float64Array;
65
+ reactions: BeamReactions;
66
+ }
67
+ interface XYSeries {
68
+ x: Float64Array;
69
+ y: Float64Array;
70
+ }
71
+ interface BeamDiagrams {
72
+ deflection: XYSeries;
73
+ moment: XYSeries;
74
+ shear: XYSeries;
75
+ }
76
+ interface DiagramOptions {
77
+ pointsPerElement?: number;
78
+ eps?: number;
79
+ includeOutsideEnds?: boolean;
80
+ }
81
+ interface MeshOptions {
82
+ maxElements?: number;
83
+ minElementsPerSegment?: number;
84
+ eps?: number;
85
+ }
86
+ interface Mesh {
87
+ nodes: Float64Array;
88
+ /**
89
+ * Find the closest node index to `x` if within `eps`, otherwise returns -1.
90
+ * This handles cases where user-provided load coordinates have small floating error.
91
+ */
92
+ findNodeIndex: (x: number, eps: number) => number;
93
+ }
94
+ interface LinearSystem {
95
+ bandedK: Float64Array;
96
+ forceVector: Float64Array;
97
+ nodePositions: Float64Array;
98
+ }
99
+ interface BoundaryConditions {
100
+ freeDofs: Int32Array;
101
+ restrainedDofs: Int32Array;
102
+ }
103
+
104
+ interface SolveOutputs {
105
+ displacements: Float64Array;
106
+ reactions: BeamReactions;
107
+ }
108
+ /**
109
+ * Pre-allocated scratch space for repeated solves on the same mesh topology.
110
+ * Create once with `createSolverBuffers(nDof)`, reuse across many solve calls.
111
+ */
112
+ interface SolverBuffers {
113
+ readonly nDof: number;
114
+ compactOf: Int32Array;
115
+ Kff: Float64Array;
116
+ Lband: Float64Array;
117
+ ff: Float64Array;
118
+ y: Float64Array;
119
+ uf: Float64Array;
120
+ u: Float64Array;
121
+ }
122
+ declare function createSolverBuffers(nDof: number): SolverBuffers;
123
+ /**
124
+ * Same as `solveLinearSystem` but uses pre-allocated buffers.
125
+ * All output arrays inside `buffers` are overwritten in place.
126
+ */
127
+ declare function solveLinearSystemBuffered(system: LinearSystem, bc: BoundaryConditions, buffers: SolverBuffers): SolveOutputs;
128
+
129
+ declare function assembleSystem(beam: BeamInput, mesh: Mesh): LinearSystem;
130
+ declare function getBoundaryConditions(beam: BeamInput, mesh: Mesh): BoundaryConditions;
131
+
132
+ declare function generateMesh(beam: BeamInput, options?: MeshOptions): Mesh;
133
+
134
+ /**
135
+ * Solves a static linear Euler-Bernoulli beam model and returns nodal responses
136
+ * (deflection/rotation, moments, shears, and support reactions).
137
+ */
138
+ declare function analyzeBeam(beam: BeamInput, meshOptions?: MeshOptions): BeamResults;
139
+ /**
140
+ * Convenience wrapper that also returns chart-ready diagram series:
141
+ * `deflection`, `moment`, and `shear`.
142
+ *
143
+ * Diagram series include discontinuity-friendly duplicate `x` coordinates.
144
+ */
145
+ declare function analyzeBeamChartReady(beam: BeamInput, meshOptions?: MeshOptions, diagramOptions?: DiagramOptions): {
146
+ results: BeamResults;
147
+ diagrams: BeamDiagrams;
148
+ };
149
+
150
+ export { type AppliedMoment, type BeamDiagrams, type BeamInput, type BeamReactions, type BeamResults, type BoundaryConditions, type DiagramOptions, type DistributedLoad, type LinearSystem, type Mesh, type MeshOptions, type PointLoad, type Support, type SupportKind, type XYSeries, analyzeBeam, analyzeBeamChartReady, assembleSystem, createSolverBuffers, generateMesh, getBoundaryConditions, solveLinearSystemBuffered };