Skip to content

Cycles and Initial Conditions

A cycle is the sequence of operating steps a bed repeats — feed, blowdown, purge, pressurisation, and so on. In Skarstrom a cycle is a list of steps, each with its own duration and its own pair of boundary conditions, executed in order and then repeated. A deck's cycle also holds the connections between steps for multi-bed processes and the KPI configuration for the performance metrics.

Start from a template. data/cycles/ holds ready-made cycles: breakthrough.json, 4_step_vpsa.json, 4_step_vpsa_lpp.json (with light-product pressurisation), skarstrom_cycle.json and 6_step_vpsa_rinse.json. They are written by core/test/unit/test_cycle_designs.cpp, which is also the clearest example of building a cycle in C++, and load with adsim::LoadCycleFromJSON. The example decks are complete processes to adapt.


Steps

Each step has a name and two boundary conditions:

  • the Top boundary at \(z = L\) (the far end of the column), and
  • the Bottom boundary at \(z = 0\) (the near end).

A step can also apply an energy source to a layer (heating or cooling). In C++ a cycle is edited with Cycle::AddStep, Cycle::GetStep, DuplicateStep (which copies a step with its settings and clears connections on the copy) and the boundary-condition factories; from Python the existing steps' values are parameters:

sim.steps                          # ['Feed', 'Blowdown', 'Evacuation', 'Pressurisation']
sim["step[Feed].time"] = 60.0      # by name (alias) ...
sim["step[1].time"] = 60.0         # ... or by the step's stable ID

A few rules are enforced by the deck checks before a run:

  • A cycle must contain at least one step, and step names must be unique.
  • The two boundaries of a step cannot both be inlets — one must be an outlet (or a closed end).
  • The Top and Bottom boundaries must be at different ends of the column.
  • A step that ends on a pressure needs a positive end pressure and no connected stream.

Number of cycles

A PSA/TSA process must run many cycles before it settles into a repeating pattern. The deck's number of cycles (cycle.number_of_cycles) is how many times the whole step sequence repeats; the total simulated time is the cycle time multiplied by the number of cycles. sim.run(cycles=N) and skarstrom run --cycles N override it for one run.

Rather than guessing the number of cycles, let the solver stop automatically once the bed stops changing from one cycle to the next — see cyclic steady state. The number of cycles is then an upper limit.

Step timing

The step time mode controls how step durations are given:

  • Absolute — each step's duration in seconds (step[...].time). The cycle time is the sum of the step times.
  • Fraction — a single total cycle time (cycle.total_time) and a fraction of it per step (step[...].fraction). The fractions must sum to 1. This makes it easy to rescale a whole cycle by changing one number.

Step times are expressions, so two steps can share a global variable (sim["step[Rinse].time"] = "t_feed").

Ending a step on a pressure

New in 0.19

Many lab and plant cycles end a blowdown, an evacuation or a pressurisation when the column reaches a set pressure, not after a set time. A step can do the same: it ends when the pressure at a bed end reaches its end pressure. The step time is then the step's maximum time: a step that does not reach the pressure ends there.

evac = sim.steps["Evacuation"]
evac.end_on_pressure(5e3, location="bottom", max_time=300)   # falls to 5 kPa, at most 300 s
sim.steps["Pressurisation"].end_on_pressure(0.95e5, location="top", direction="rising", max_time=60)
  • Pressure — the bed-end face pressure at location ("bottom" or "top"), the value that sim.series("pressure", location=...) gives. With point="end_cell" the step watches the pressure of the packed cell at that end instead (no void cell), the first cell of the bed_min, bed_mean and bed_max step-end pressures. New in 0.20.
  • Direction — "falling", "rising" or "auto" (the default: rising when the step starts below the end pressure, else falling). With an explicit direction, a step that starts past the end pressure runs until the pressure crosses it in that direction, or to its maximum time.
  • Exact end — the solver finds the crossing with the integrator's root finder, so the step ends at the crossing to the integrator's tolerance, not at the next logged point.

The parameters are step[...].end_condition.enabled, .bed_end ("bottom" or "top"), .direction, .pressure (in Pa) and .point ("face" or "end_cell"; New in 0.20), so a sweep or the CLI can set them (--set "step[Evacuation].end_condition.enabled=true"). While the condition is enabled, step[...].time is the maximum time.

sim.steps["Evacuation"].end_on_pressure(5e3, location="bottom", point="end_cell", max_time=300)

Where to measure: the face pressure is what a pressure gauge at the column end reads and what the boundary condition sets; the end cell is the first packed cell, which lags the face when the end changes fast (a blowdown on a set boundary pressure reaches the target at the face first). Pick the one your reference measures. An optimiser or a study that bounds the same step's end_pressure_bottom reads the face value.

The step lengths and the cycle time are then results. sim.step_end_pressures(cycle) gives, for each step, its duration [s], triggered (the end pressure stopped the step) and time (the step's end from the cycle start; the last step's value is the cycle time). The productivity and the production rate divide by this measured cycle time. Without an end condition, a deck runs and saves as before.

sim.run(cycles=1)
for r in sim.step_end_pressures():
    print(r.step_name, round(r.duration, 1), r.triggered)

A step that ends on a pressure cannot have a connected stream: a connection replays its partner step over the same step time. Nor can it be in a cycle whose step times are fractions of the cycle time (cycle.step_time_mode fraction): the run stops at its checks with a message. Use time mode.

A target the step does not reach. The step then runs to its maximum time, and its length, the cycle time and the KPIs follow from that cap, not from the end pressure. The run still completes, with the run-health warning END_PRESSURE_NOT_REACHED: it names the step, the cycle (the last one that missed) and the pressure the step ended at. New in 0.20.

result = sim.run(cycles=1)
for w in result.warnings:
    if w.code == "END_PRESSURE_NOT_REACHED":
        print(w.step_name, w.cycle, w.value, w.threshold)   # pressure at the end, end pressure [Pa]

Cyclic steady state. The step lengths are part of the CSS test: a run stops only when they have settled as well. New in 0.20.

Warm starts, studies, optimisation and calibration run on a deck with an end condition as on any other deck. A warm start begins from the bed state of a cached cyclic steady state; the step lengths follow from that state. The forward cycle-sensitivity prototype does not accept such a deck.


Initial conditions

The initial conditions set the state of the bed everywhere at \(t = 0\), before the first step begins:

  • Pressure
  • Bed temperature (the initial gas and solid temperature)
  • Wall temperature
  • Velocity
  • Initial mole fraction for each component — these must sum to 1.

Choose initial conditions that are physically consistent with the first step's boundary conditions; for example, if the first step feeds gas at high pressure into an evacuated bed, start from a low pressure. A poor initial guess can make the first solve harder to converge. (If the model reaches cyclic steady state, the initial condition only affects how many cycles that takes, not the final answer.)


Next: define what happens at each end of the column in Boundary Conditions.