1 electric car uses 20 kWh/100 km, i.e. 500 km car drive.

SPS MBI power usage

A script to compute the SPS MBI power usage (in kWh) exists at https://gitlab.cern.ch/-/snippets/2739, under the assumption that the resistance is 3.28 mOhm for 744 magnets in series.

Alternatively

"""
This script calculates the energy wasted in a cycle by the dipole magnets for
a certain cycle.
The script calculates the energy waste by integrating the effect of the magnet
over time, assuming a fixed resistance, using the programmed current in LSA.
Usage:
    python calc_dipole_power_usage.py <cycle_selector> --start <start> --stop <stop>
Where:
    <cycle_selector> is the selector of the cycle to be analyzed
    <start> is the start of the cycle to be analyzed (ms)
    <stop> is the end of the cycle to be analyzed (ms)
E.g. python calc_dipole_power_usage.py SPS.USER.SFTPRO2 --start 2000
for calculating power usage from 2000ms to the end of the cycle.
"""
import argparse
import numpy as np
import pyda
import pyda_lsa
import pyrbac
 
 
R = 3.28e-3 * 744  # Ohm
 
 
# pyright: reportPrivateImportUsage=false
def main() -> None:
    parser = argparse.ArgumentParser(
        description="Calculate the energy wasted in a cycle by the dipole"
    )
    
    parser.add_argument("selector", help="Selector of the cycle to be analyzed")
    parser.add_argument(
        "--start", help="Start of the cycle to be analyzed (ms)", type=int, default=0
    )
    parser.add_argument(
        "--stop", help="End of the cycle to be analyzed (ms)", type=int, default=-1
    )
    
    args = parser.parse_args()
    
    calc_dipole_power_usage(args.selector, args.start, args.stop)
 
 
def calc_dipole_power_usage(
    selector: str = "SPS.USER.SFTPRO2", start: int = 0, stop: int = -1
) -> None:
    token = pyrbac.AuthenticationClient().login_location()
    provider = pyda_lsa.LsaProvider(server="sps", rbac_token=token)
    da = pyda.SimpleClient(provider=provider)
    
    value = da.get(
        endpoint=pyda_lsa.LsaEndpoint.from_str("MBI/IREF"),
        context=pyda_lsa.LsaCycleContext(cycle=selector),
    )
    
    iref_df = value.value["value"]
    
    ms = np.arange(iref_df.xs[-1])  # ms
    iref_interp = np.interp(ms, iref_df.xs, iref_df.ys)  # A
    
    if stop == -1:
        stop = len(iref_interp)
    iref_interp_slice = iref_interp[start:stop]
    
    def I_to_kWH(I: np.ndarray) -> np.float_:
        return np.trapz((I**2) * R) / (1e3 * 3.6e3 * 1e3)
        
    E_slice = I_to_kWH(iref_interp_slice)
    E_full = I_to_kWH(iref_interp)
    
    print(f"Energy wasted: {E_slice:.2f} kWh")
    print(f"Normal cycle energy: {E_full:.2f} kWh")
    
    print(f"Efficiency: {(1- E_slice / E_full) * 100:.2f} %")
    
    print("Assuming power cost of 0.15 CHF/kWh:")
    print(f"Cost of wasted energy: {E_slice * 0.15:.2f} CHF per cycle")
    
    print("Assuming 4 cycles per minute, for one hour:")
    print(f"Cost of wasted energy: {E_slice * 0.15 * 4 * 60:.2f} CHF per hour")
 
 
if __name__ == "__main__":
    main()