Skip to content

Commit

Permalink
build-h-functionとunitのメソッド名を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
st-func committed Feb 11, 2024
1 parent ddb12e0 commit 89afb00
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 35 deletions.
26 changes: 14 additions & 12 deletions src/sec/build-h-function.test.ts
Expand Up @@ -7,10 +7,10 @@ test("ビルドHのA", () => {
const T1 = 0.019;
const T2 = 0.025;
const A = 4.185e-2;
expect(SecBuildHFunction.build_h_area(H, B, T1, T2)).toBe(A);
expect(
SecBuildHFunction.build_h(SectionPropertyType.Area, H, B, T1, T2)
).toBe(A);
expect(SecBuildHFunction.buildHArea(H, B, T1, T2)).toBe(A);
expect(SecBuildHFunction.buildH(SectionPropertyType.Area, H, B, T1, T2)).toBe(
A
);
});

test("ビルドHのIy", () => {
Expand All @@ -20,11 +20,12 @@ test("ビルドHのIy", () => {
const T2 = 0.025;
const IY = 9.31221875e-3;
const NUM_DIGITS = 17;
expect(SecBuildHFunction.buildHSecondMomentOfAreaY(H, B, T1, T2)).toBeCloseTo(
IY,
NUM_DIGITS
);
expect(
SecBuildHFunction.build_h_second_moment_of_area_y(H, B, T1, T2)
).toBeCloseTo(IY, NUM_DIGITS);
expect(
SecBuildHFunction.build_h(
SecBuildHFunction.buildH(
SectionPropertyType.SecondMomentOfAreaY,
H,
B,
Expand All @@ -41,11 +42,12 @@ test("ビルドHのIz", () => {
const T2 = 0.025;
const IZ = 2.673239875e-4;
const NUM_DIGITS = 18;
expect(SecBuildHFunction.buildHSecondMomentOfAreaZ(H, B, T1, T2)).toBeCloseTo(
IZ,
NUM_DIGITS
);
expect(
SecBuildHFunction.build_h_second_moment_of_area_z(H, B, T1, T2)
).toBeCloseTo(IZ, NUM_DIGITS);
expect(
SecBuildHFunction.build_h(
SecBuildHFunction.buildH(
SectionPropertyType.SecondMomentOfAreaZ,
H,
B,
Expand Down
14 changes: 7 additions & 7 deletions src/sec/build-h-function.ts
Expand Up @@ -11,7 +11,7 @@ export class SecBuildHFunction {
* @param t2 フランジ厚 t2
* @returns 断面積 A
*/
static build_h_area(a: number, b: number, t1: number, t2: number): number {
static buildHArea(a: number, b: number, t1: number, t2: number): number {
return a * b - (a - 2 * t2) * (b - t1);
}
/**
Expand All @@ -22,7 +22,7 @@ export class SecBuildHFunction {
* @param t2 フランジ厚 t2
* @returns 断面二次モーメント(強軸)Iy
*/
static build_h_second_moment_of_area_y(
static buildHSecondMomentOfAreaY(
a: number,
b: number,
t1: number,
Expand All @@ -38,7 +38,7 @@ export class SecBuildHFunction {
* @param t2 フランジ厚 t2
* @returns 断面二次モーメント(弱軸) Iz
*/
static build_h_second_moment_of_area_z(
static buildHSecondMomentOfAreaZ(
a: number,
b: number,
t1: number,
Expand All @@ -55,7 +55,7 @@ export class SecBuildHFunction {
* @param t2 フランジ厚 t2
* @returns 断面性能
*/
static build_h(
static buildH(
propertyType: SectionPropertyType,
a: number,
b: number,
Expand All @@ -64,11 +64,11 @@ export class SecBuildHFunction {
): number {
switch (propertyType) {
case SectionPropertyType.Area:
return SecBuildHFunction.build_h_area(a, b, t1, t2);
return SecBuildHFunction.buildHArea(a, b, t1, t2);
case SectionPropertyType.SecondMomentOfAreaY:
return SecBuildHFunction.build_h_second_moment_of_area_y(a, b, t1, t2);
return SecBuildHFunction.buildHSecondMomentOfAreaY(a, b, t1, t2);
case SectionPropertyType.SecondMomentOfAreaZ:
return SecBuildHFunction.build_h_second_moment_of_area_z(a, b, t1, t2);
return SecBuildHFunction.buildHSecondMomentOfAreaZ(a, b, t1, t2);
default:
throw new Error("実装していない断面性能です。");
}
Expand Down
28 changes: 14 additions & 14 deletions src/unit.test.ts
Expand Up @@ -28,19 +28,19 @@ test("単位の係数取得", () => {

test("単位の変換", () => {
//入力
expect(Unit.in(5.0, "m")).toBe(5.0);
expect(Unit.in(5.0, "mm")).toBe(0.005);
expect(Unit.in(5.0, "kg")).toBe(5.0);
expect(Unit.in(5.0, "kN")).toBe(5000.0);
expect(Unit.in(5.0, "kN/m")).toBe(5000.0);
expect(Unit.in(5.0, "mm^2")).toBeCloseTo(5e-6, 20);
expect(Unit.in(5.0, "N/mm^2")).toBe(5e6);
expect(Unit.input(5.0, "m")).toBe(5.0);
expect(Unit.input(5.0, "mm")).toBe(0.005);
expect(Unit.input(5.0, "kg")).toBe(5.0);
expect(Unit.input(5.0, "kN")).toBe(5000.0);
expect(Unit.input(5.0, "kN/m")).toBe(5000.0);
expect(Unit.input(5.0, "mm^2")).toBeCloseTo(5e-6, 20);
expect(Unit.input(5.0, "N/mm^2")).toBe(5e6);
//出力
expect(Unit.out(5.0, "m")).toBe(5.0);
expect(Unit.out(5.0, "mm")).toBe(5000.0);
expect(Unit.out(5.0, "kg")).toBe(5.0);
expect(Unit.out(5.0, "kN")).toBe(0.005);
expect(Unit.out(5.0, "kN/m")).toBe(0.005);
expect(Unit.out(5.0, "mm^2")).toBe(5e6);
expect(Unit.out(5.0, "N/mm^2")).toBe(5e-6);
expect(Unit.output(5.0, "m")).toBe(5.0);
expect(Unit.output(5.0, "mm")).toBe(5000.0);
expect(Unit.output(5.0, "kg")).toBe(5.0);
expect(Unit.output(5.0, "kN")).toBe(0.005);
expect(Unit.output(5.0, "kN/m")).toBe(0.005);
expect(Unit.output(5.0, "mm^2")).toBe(5e6);
expect(Unit.output(5.0, "N/mm^2")).toBe(5e-6);
});
4 changes: 2 additions & 2 deletions src/unit.ts
Expand Up @@ -82,7 +82,7 @@ export class Unit {
* @param unit_from 単位
* @returns 計算用数値
*/
static in(value: number, unit_from: string): number {
static input(value: number, unit_from: string): number {
return value * this.factor(unit_from);
}

Expand All @@ -92,7 +92,7 @@ export class Unit {
* @param unit_to 単位
* @returns 単位付き数値
*/
static out(value: number, unit_to: string): number {
static output(value: number, unit_to: string): number {
return value / this.factor(unit_to);
}
}

0 comments on commit 89afb00

Please sign in to comment.