Skip to content

Commit

Permalink
Added profile tissues tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Jan 9, 2025
1 parent d41d4d8 commit 5275486
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
3 changes: 2 additions & 1 deletion projects/planner/src/app/workers/planning.tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export class PlanningTasks {
const averageDepth = Segments.averageDepth(originalProfile);

const profileTissues = new ProfileTissues();
const surfaceGradient = profileTissues.surfaceGradient(parameters.surfaceInterval.previousTissues);
const loadedTissues = parameters.surfaceInterval.previousTissues;
const surfaceGradient = profileTissues.surfaceGradient(loadedTissues, depthConverter.surfacePressure);
const offgasingStart = profileTissues.offgasingStart([]); // TODO fill the overpressures parameter

return {
Expand Down
33 changes: 33 additions & 0 deletions projects/scuba-physics/src/lib/ProfileTissues.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ProfileTissues } from "./ProfileTissues";
import { LoadSegment, Tissues } from "./Tissues";
import { StandardGases } from "./StandardGases";
import { Time } from "./Time";

describe('Profile tissues', () => {
const sut = new ProfileTissues();
const surfacePressure = 1;

xdescribe('Surface gradient', () => {
it('Not loaded at surface Is 0 %', () => {
const loadedTissues = Tissues.create(surfacePressure).finalState();
const result = sut.surfaceGradient(loadedTissues, surfacePressure);
expect(result).toBe(0);
});

it('Is XX % when loaded', () => {
const loadSegment = new LoadSegment(2, Time.oneMinute * 20, 0);
const tissues = Tissues.create(surfacePressure);
tissues.load(loadSegment, StandardGases.air);
const loadedTissues = tissues.finalState();
const result = sut.surfaceGradient(loadedTissues, surfacePressure);
expect(result).toBe(0);
});

it('Loaded at altitude is still 0 %', () => {
const altitudePressure = 0.8;
const loadedTissues = Tissues.create(altitudePressure).finalState();
const result = sut.surfaceGradient(loadedTissues, surfacePressure);
expect(result).toBe(0);
});
});
});
6 changes: 4 additions & 2 deletions projects/scuba-physics/src/lib/Tissues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,10 @@ export class Tissues {
* @param ambientPressure in bars (e.g. surface or ambient).
*/
public gradientFactor(ambientPressure: number): number {
// TODO implement gradient factor for tissues
return 0;
const maxGradient = _(this._compartments)
.map(t => t.gradientFactor(ambientPressure))
.max() || 0;
return maxGradient;
}
}

Expand Down

0 comments on commit 5275486

Please sign in to comment.