Jaap Voets


SCUBA::Blender - Module for calculating gas pressures for blending Nitrox or Trimix


use SCUBA::Blender;

my $blender = new SCUBA::Blender()

# start with 20 bar of air

$blender->start_mix( 20, 'O2' => 21);

# calculate for 230 bar of Nitrox 32%

$blender->end_mix( 230, 'O2' => 32);


print $blender->report();


None by default.


This package uses the van der Waals equation to calculate the needed pressures for blending Nitrox and Trimix for (technical) scuba diving.

You set the starting pressure and mix (leftover gases from previous dive) and specify the desired mix and pressure. The program will then calculate how much of each gas you have to add. With the ideal gas law you are usually not too much off when blending Nitrox to 200 bar. But with Helium and higher pressures, van der Waals is much preciser.

At the moment the SCUBA::Blender package is metric only.



Constructor, creates a new blender object.

E.g. my $blender = new SCUBA::Blender;

volume( $volume )

Set the volume of the tank used to blend in. Defaults to 10 liters.

E.g. $blender->volume(24);

temperature( $temperature )

Set the temperature of the gas mix. Defaults to 20 degrees celsius (293 Kelvin)

E.g $blender->temperature( 10 );

start_mix( $pressure, $gas1 => $percentage1, $gas2 => $percentage2 , ...)

Set the mix to start with (that is the stuff left in your tank from a previous dive), pressure should be given in bar. Valid gases are O2 (oxygen), He (helium) , N2 (nitrogen). You can omit the N2 and He. When N2 is missing , it will be calculated based upon the other percentages. Missing Helium will result in a Nitrox blend instead of a trimix one.


25 bar of air left: $blender->start_mix( 25, 'O2' => 21 );

40 bar of nitrox 33%: $blender->start_mix( 40, 'O2' => 33 );

70 bar of trimix 16/50: $blender->start_mix( 70, 'O2' => 16, 'He' => 50);

end_mix( $pressure, $gas1 => $percentage1, ...)

Same as with start_mix().

E.g. I want 235 bar of trimix 13/60

 $blender->start_mix( 235, 'O2' => 13, 'He' => 60);

Perform the actual calculation

E.g. $blender->calc();


Return the results of the calculation.

E.g. print $blender->report();


Jaap Voets, <narked@xperience-automatisering.nl>


Copyright (C) 2006 by Jaap Voets

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.