librasteve / raku-Physics-Measure

do calculations on objects with value, units and error
Artistic License 2.0
11 stars 2 forks source link

Support Agri Emissions (and other Chemical Brothers) #36

Closed librasteve closed 3 years ago

librasteve commented 3 years ago

https://uk-air.defra.gov.uk/assets/documents/reports/empire/naei/annreport/annrep99/app1_212.html

eg. kg N / year eg. kg CH4/head/year

also ...

N2O(AWMS) = 44/28 . å NT . Nex(T) . AWMS(T) . EF(AWMS) where N2O(AWMS) = N2O emissions from animal waste managment systems (kg N2O/yr) NT = Number of animals of type T Nex(T) = N excretion of animals of type T (kg N/animal/yr) AWMS(T) = Fraction of Nex that is managed in one of the different waste management systems of type T EF(AWMS) = N2O emission factor for an AWMS (kg N2O-N/kg of Nex in AWMS)

librasteve commented 3 years ago

1 #!/usr/bin/env raku 2 use lib '../lib'; 3 use Physics::Unit; 4 use Physics::Measure; 5 6 my $nempu = Unit.new( defn => 'kg/year', names => ['kg N/year'] ); 7 $nempu.NewType( 'Emissions' ); 8 class Emissions is Measure {} 9 10 my $em1 ♎️ '11 kg N/year'; 11 say "Result one is $em1 of ", $em1.WHAT; 12 13 Unit.new( defn => 'kg/year', names => ['kg CH₄/year'] ); #subscript 4 is (U+2084) 14 15 my $em2 ♎️ '16 kg CH₄/year'; 16 say "Result two is $em2 of {$em2.units.type}…"; 17 say "…which is {$em2.pretty} in SI Units."; 18

Now gives the right answers… (will take a few days to release this version)

Result one is 11 kg N/year of (Emissions)

Result two is 16 kg CH₄/year of Emissions……which is 0.00000051 kg⋅s⁻¹ in SI Units.