Skip to content

Commit

Permalink
fix(textile): distribution step had no inland road transports added. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Sep 19, 2024
1 parent a85bd8a commit d789d7d
Show file tree
Hide file tree
Showing 4 changed files with 344 additions and 348 deletions.
14 changes: 5 additions & 9 deletions src/Data/Textile/Step.elm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Data.Transport as Transport exposing (Transport)
import Data.Unit as Unit
import Energy exposing (Energy)
import Json.Encode as Encode
import Length
import Mass exposing (Mass)
import Quantity
import Static.Db exposing (Db)
Expand Down Expand Up @@ -221,15 +222,14 @@ computeTransportImpacts impacts { airTransport, seaTransport } roadProcess mass
computeTransportSummary : Step -> Transport -> Transport
computeTransportSummary step transport =
let
( noTransports, defaultInland ) =
( Transport.default step.transport.impacts
, Transport.default step.transport.impacts
)
noTransports =
Transport.default step.transport.impacts
in
case step.label of
Label.Distribution ->
-- Product Distribution leverages no transports
-- Add default road transport to materialize transport to/from a warehouse
noTransports
|> Transport.add { noTransports | road = Length.kilometers 500 }

Label.EndOfLife ->
-- End of life leverages no transports
Expand All @@ -239,10 +239,6 @@ computeTransportSummary step transport =
-- Air transport only applies between the Making and the Distribution steps
transport
|> Formula.transportRatio step.airTransportRatio
-- Added intermediary inland transport distances to materialize
-- transport to the "distribution" step
-- Also ensure we don't add unnecessary air transport
|> Transport.add { defaultInland | air = Quantity.zero }

Label.Use ->
-- Product Use leverages no transports
Expand Down
4 changes: 2 additions & 2 deletions tests/Data/Textile/LifeCycleTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ suite =
|> Result.andThen (lifeCycleToTransports db tShirtCotonFrance)
|> Result.map LifeCycle.computeTotalTransportImpacts
|> Result.map (\{ road, sea } -> ( Length.inKilometers road, Length.inKilometers sea ))
|> Expect.equal (Ok ( 2000, 21549 ))
|> Expect.equal (Ok ( 2500, 21549 ))
|> asTest "should compute default distances"
, let
tShirtCotonEnnoblementIndia =
Expand All @@ -46,7 +46,7 @@ suite =
|> Result.andThen (lifeCycleToTransports db tShirtCotonEnnoblementIndia)
|> Result.map LifeCycle.computeTotalTransportImpacts
|> Result.map (\{ road, sea } -> ( Length.inKilometers road, Length.inKilometers sea ))
|> Expect.equal (Ok ( 1000, 45471 ))
|> Expect.equal (Ok ( 1500, 45471 ))
|> asTest "should compute custom distances"
]
]
Expand Down
2 changes: 1 addition & 1 deletion tests/Data/Textile/SimulatorTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ suite =
[ { tShirtCotonFrance
| countrySpinning = Nothing
}
|> expectImpact db ecs 1469.1531378179673
|> expectImpact db ecs 1471.1431913678628
|> asTest "should compute a simulation ecs impact"
, describe "disabled steps"
[ { tShirtCotonFrance | disabledSteps = [ Label.Ennobling ] }
Expand Down
Loading

0 comments on commit d789d7d

Please sign in to comment.