-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jiri Pokorny
committed
Oct 3, 2023
1 parent
0e6d060
commit d212d51
Showing
5 changed files
with
165 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { GasProperties } from './gas.properties'; | ||
|
||
describe('Gas properties calculator', () => { | ||
let sut: GasProperties; | ||
|
||
beforeEach(() => { | ||
sut = new GasProperties(); | ||
sut.depth = 30; | ||
}); | ||
|
||
describe('Air at 30 m', () => { | ||
beforeEach(() => { | ||
sut.tank.o2 = 21; | ||
}); | ||
|
||
it('MND is 30 m', () => { | ||
expect(sut.mnd).toBeCloseTo(30, 3); | ||
}); | ||
|
||
it('END is 30 m', () => { | ||
expect(sut.end).toBeCloseTo(30, 3); | ||
}); | ||
|
||
it('Minimum depth is 0 m', () => { | ||
expect(sut.minDepth).toBeCloseTo(0, 3); | ||
}); | ||
|
||
it('Maximum depth (MOD) is 57 m', () => { | ||
expect(sut.maxDepth).toBeCloseTo(56.986, 3); | ||
}); | ||
|
||
it('Total partial pressure is depth (4 b)', () => { | ||
expect(sut.totalPp).toBeCloseTo(4, 3); | ||
}); | ||
|
||
it('ppO2 is 0.836', () => { | ||
expect(sut.ppO2).toBeCloseTo(0.836, 3); | ||
}); | ||
|
||
it('ppHe is 0', () => { | ||
expect(sut.ppHe).toBeCloseTo(0, 3); | ||
}); | ||
|
||
it('ppN2 is 3.164', () => { | ||
expect(sut.ppN2).toBeCloseTo(3.164, 3); | ||
}); | ||
|
||
it('Density is 5.15 g/l', () => { | ||
expect(sut.density).toBeCloseTo(5.151972, 6); | ||
}); | ||
}); | ||
|
||
describe('Trimix 10/70 at 30 m', () => { | ||
beforeEach(() => { | ||
sut.tank.o2 = 10; | ||
sut.tank.he = 70; | ||
}); | ||
|
||
it('MND is 123.3 m', () => { | ||
expect(sut.mnd).toBeCloseTo(123.333, 3); | ||
}); | ||
|
||
it('END is 2 m', () => { | ||
expect(sut.end).toBeCloseTo(2, 3); | ||
}); | ||
|
||
it('Minimum depth is 8 m', () => { | ||
expect(sut.minDepth).toBeCloseTo(8, 3); | ||
}); | ||
|
||
it('Maximum depth (MOD) is 130 m', () => { | ||
expect(sut.maxDepth).toBeCloseTo(130, 3); | ||
}); | ||
|
||
it('ppO2 is 0.4', () => { | ||
expect(sut.ppO2).toBeCloseTo(0.4, 3); | ||
}); | ||
|
||
it('ppHe is 2.8', () => { | ||
expect(sut.ppHe).toBeCloseTo(2.8, 3); | ||
}); | ||
|
||
it('ppN2 is 0.8', () => { | ||
expect(sut.ppN2).toBeCloseTo(0.8, 3); | ||
}); | ||
|
||
it('Density is 2 g/l', () => { | ||
expect(sut.density).toBeCloseTo(2.0732, 6); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { DensityAtDepth } from './GasDensity'; | ||
import { Gas, GasMixtures } from './Gases'; | ||
import { Tank } from './Tanks'; | ||
import { DepthConverter } from './depth-converter'; | ||
|
||
export class GasProperties { | ||
/** in meters */ | ||
public depth = 0; | ||
private readonly _tank = Tank.createDefault(); | ||
private readonly depthConverter = DepthConverter.simple(); | ||
private readonly densityCalc = new DensityAtDepth(this.depthConverter); | ||
|
||
public get tank(): Tank { | ||
return this._tank; | ||
} | ||
|
||
public get ppO2(): number { | ||
const result = GasMixtures.partialPressure(this.depthPressure, this.gas.fO2); | ||
return result; | ||
} | ||
|
||
public get ppHe(): number { | ||
const result = GasMixtures.partialPressure(this.depthPressure, this.gas.fHe); | ||
return result; | ||
} | ||
|
||
public get ppN2(): number { | ||
const result = GasMixtures.partialPressure(this.depthPressure, this.gas.fN2); | ||
return result; | ||
} | ||
|
||
public get totalPp(): number { | ||
return this.depthPressure; | ||
} | ||
|
||
public get minDepth(): number { | ||
const surface = this.depthConverter.surfacePressure; | ||
const minDepthPressure = GasMixtures.ceiling(this.gas.fO2, surface); | ||
return this.depthConverter.fromBar(minDepthPressure); | ||
} | ||
|
||
public get maxDepth(): number { | ||
const maxppO2 = 1.4; // TODO add to UI | ||
const maxDepthPressure = GasMixtures.mod(1.4, this.gas.fO2); | ||
return this.depthConverter.fromBar(maxDepthPressure); | ||
} | ||
|
||
public get end(): number { | ||
const endDepthPressure = GasMixtures.end(this.depthPressure, this.gas.fN2, this.gas.fO2); | ||
return this.depthConverter.fromBar(endDepthPressure); | ||
} | ||
|
||
public get mnd(): number { | ||
const narcDepthBars = 4; // TODO add to UI | ||
const endDepthPressure = GasMixtures.mnd(narcDepthBars, this.gas.fN2, this.gas.fO2); | ||
return this.depthConverter.fromBar(endDepthPressure); | ||
} | ||
|
||
public get density(): number { | ||
const density = this.densityCalc.atDepth(this.gas, this.depth); | ||
return density; | ||
} | ||
|
||
private get gas(): Gas { | ||
return this.tank.gas; | ||
} | ||
|
||
private get depthPressure(): number { | ||
return this.depthConverter.toBar(this.depth); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters