kaelyndunnell / hisp

Hydrogen Inventory Simulations for PFCs (HISP) is a series of code that uses FESTIM to simulate deuterium and tritium inventories in a fusion tokamak first wall and divertor PFCs.
https://hisp.readthedocs.io
MIT License
2 stars 0 forks source link

Convenience functions for pulses #35

Open RemDelaporteMathurin opened 4 weeks ago

RemDelaporteMathurin commented 4 weeks ago

It would be convenient to have functions like periodic step function, periodic step function with ramp up/down etc.

def periodic_step_function(x, period_on, period_total, value_on, value_off=0.0):
    """
    Creates a periodic step function with two periods.
    """

    if period_total < period_on:
        raise ValueError("period_total must be greater than period_on")

    if x % period_total < period_on:
        return value_on
    else:
        return value_off