def input_profile(t, x0):
    """
    calculate the user input x as a function of time
    x0 is the initial value
    ramp down from 100% to 50% load at 5%/min rate
    hold for half an hour
    ramp up from 50% to 100% load at 5%/min rate
    hold for 20 minutes
    """
    if t < 60:
        x = x0
    elif t < 660:
        x = x0*(1-(t-60)/600*0.5)
    elif t < 2460:
        x = x0*0.5
    elif t < 3060:
        x = x0*(0.5+(t-2460)/600*0.5)
    else:
        # Hold for 1200 sec to 4260 sec
        x = x0
    return x