 (def rand-pressure-unit (rand-unit :pressure))
 (def rand-proppant-concentration-unit (rand-unit :proppant-concentration))
 (def rand-slurry-rate-unit (rand-unit :slurry-rate))
+(def rand-temperature-unit (rand-unit :temperature))
 (def rand-volume-unit (rand-unit :volume))
 
 (defn convert-units-f [from to]
-  (let [factors   {[:m :ft]                   3.28084
+  (let [factors   {[:lb-per-cu-ft :kg-per-m3] 16.0185
+                   [:m :ft]                   3.28084
                    [:kg :lb]                  2.20462262185
-                   [:m3 :bbl]                 6.28981077
                    [:psi :kPa]                6.894757293168361
                    [:lb-per-gal :kg-per-m3]   119.826
-                   [:lb-per-cu-ft :kg-per-m3] 16.0185}
-        converter {[:ft :m]                   #(/ % (factors [:m :ft]))
+                   ;; slurry rate conversion not needed (use [:bbl :m3])
+                   [:m3 :bbl]                 6.28981077}
+        converter {[:lb-per-cu-ft :kg-per-m3] #(* % (factors [:lb-per-cu-ft :kg-per-m3]))
+                   [:kg-per-m3 :lb-per-cu-ft] #(/ % (factors [:lb-per-cu-ft :kg-per-m3]))
+                   [:ft :m]                   #(/ % (factors [:m :ft]))
                    [:m :ft]                   #(* % (factors [:m :ft]))
                    [:lb :kg]                  #(/ % (factors [:kg :lb]))
                    [:kg :lb]                  #(* % (factors [:kg :lb]))
-                   [:bbl :m3]                 #(/ % (factors [:m3 :bbl]))
-                   [:m3 :bbl]                 #(* % (factors [:m3 :bbl]))
                    [:psi :kPa]                #(* % (factors [:psi :kPa]))
                    [:kPa :psi]                #(/ % (factors [:psi :kPa]))
                    [:lb-per-gal :kg-per-m3]   #(* % (factors [:lb-per-gal :kg-per-m3]))
                    [:kg-per-m3 :lb-per-gal]   #(/ % (factors [:lb-per-gal :kg-per-m3]))
                    [:m3-per-min :bbl-per-min] #(* % (factors [:m3 :bbl]))
                    [:bbl-per-min :m3-per-min] #(/ % (factors [:lb-per-gal :kg-per-m3]))
-                   [:lb-per-cu-ft :kg-per-m3] #(* % (factors [:lb-per-cu-ft :kg-per-m3]))
-                   [:kg-per-m3 :lb-per-cu-ft] #(/ % (factors [:lb-per-cu-ft :kg-per-m3]))
-                   [:C :F]                    #(+ (* % 1.8) 32)}]
+                   [:F :C]                    #(/ (- % 32) 1.8)
+                   [:C :F]                    #(+ (* % 1.8) 32)
+                   [:bbl :m3]                 #(/ % (factors [:m3 :bbl]))
+                   [:m3 :bbl]                 #(* % (factors [:m3 :bbl]))}]
     (converter [from to])))
 
 (defn typical-vertical-depth []

                          :pressure
                          :proppant-concentration
                          :slurry-rate
                          :volume])

(defn rand-physical-quantity []

                            :pressure               [:psi :kPa]
                            :proppant-concentration [:lb-per-gal :lb/gal :kg-per-m3 :kg/m3]
                            :slurry-rate            [:bbl-per-min :bpm :m3-per-min :m3/min]
                            :volume                 [:bbl :m3]
                            :temperature            [:F :C]}]
    (fn [] (rand-nth (get quantity-units-map physical-quantity)))))

(def rand-density-unit (rand-unit :density))
