Skip to content

Instantly share code, notes, and snippets.

@mys721tx
Created April 5, 2026 22:08
Show Gist options
  • Select an option

  • Save mys721tx/e31de141057f07b778d9680432cecb79 to your computer and use it in GitHub Desktop.

Select an option

Save mys721tx/e31de141057f07b778d9680432cecb79 to your computer and use it in GitHub Desktop.
Separative work unit calculation
import math
def val(x):
"""Value function V(x)."""
if x == 0 or x == 1:
return 0
return (1 - 2 * x) * math.log((1 - x) / x)
def fed(p, xp, xf, xw):
"""Calculate feed mass."""
return p * (xp - xw) / (xf - xw)
def tail(p, xp, xf, xw):
"""Calculate tails mass."""
return p * (xp - xf) / (xf - xw)
def swu(f, xf, p, xp, w, xw):
"""Calculate SWU."""
return p * val(xp) + w * val(xw) - f * val(xf)
# Example data
xf = 0.00711 # feed assay
xp = 0.95 # product assay
xw = 0.002 # tails assay
p = 2000 # product mass in kg
# Calculate feed and tails mass
f = fed(p, xp, xf, xw)
w = tail(p, xp, xf, xw)
# Calculate SWU
result = swu(f, xf, p, xp, w, xw)
# Calculate power consumption
kWh_per_swu = 2500 # kWh per SWU
power = result * kWh_per_swu
print(f"Product mass: {p:.2f} kg")
print(f"Feed mass: {f:.2f} kg")
print(f"Tails mass: {w:.2f} kg")
print(f"Separative Work Units (SWU): {result:.2f} SWU")
print(f"Power consumption: {power:.2f} kWh")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment