Chapter 13
Case studies
Three case studies combine the methods of the book on process data. The first analyses a campaign of grade changes of a polymerization reactor: where the steady grades and the transitions are, which grade the reactor is in, and which periods identify its kinetics. The second identifies the operating regions of a pH neutralization process by their local dynamics. The third turns the recurring regimes of a process into rules, a transition network and explanations of every switch. Together they show the typical workflow: segment, label, explain, and select data for modelling.
13.1 Grade transitions of a polymerization reactor
The isothermal free-radical polymerization of methyl methacrylate in a continuous stirred tank [90] is the case study of Dobos, Bankó and Abonyi [11, 12]. The reactor has four states – the monomer and initiator concentrations and the zeroth and first moments of the dead polymer chains – one input, the initiator flow , and one output, the number-average molecular weight ; the nominal flow gives . simulate_mma_cstr integrates the model with the parameters of MMA_PARAMETERS. The campaign of fig. 13.1 produces three grades in the order A, B, C, B, A, C, A, with ramped transitions and small moves of the operators.
Grades and transitions. A penalized bottom-up segmentation with the Gaussian cost followed by the clustering of the segment models into three states labels the record (StateSegmenter). The state sequence reads A, B, C, B, A, (B), C, (B), A: the two direct transitions between A and C pass through the molecular weight of grade B and are labelled B, which is correct from the point of view of the product and a reminder that a transition is not a grade. The transition network gives the hours spent in every grade.
seg = sg.StateSegmenter( segmenter=sg.BottomUp("normal", penalty=40, initial_size=10), n_states=3 ).segment(X) print("segments:", seg.n_segments, "| grade sequence:", seg.labels.tolist()) G = transition_graph(seg, sampling_period=0.05) print( {v: round(G.nodes[v]["total_duration"], 1) for v in G.nodes}, "hours per state", )
Open in ColabExample plot_01_polymer_grades.py in the gallery
Informative periods. Which parts of the record identify the propagation and initiator decomposition rate constants? The Fisher-information segmentation of section 5.5, with sensitivities computed by finite differences of the simulator, ranks the transitions far above the steady grades (fig. 13.2). An identification data set built from the transitions is short and informative; long steady operation adds little – the conclusion of the segmentation-based experiment design of Dobos et al.
names = ["kp", "kI"] p0 = np.array([MMA_PARAMETERS[k] for k in names]) S = sg.finite_difference_sensitivities( lambda p: simulate_mma_cstr(FI, params=dict(zip(names, p, strict=True))), p0, rel_step=1e-4, ) fs = sg.FisherSegmenter( n_segments=seg.n_segments, criterion="logD", window=20, initial_size=10 ).fit(S) print( fs.ranking_[["start", "stop", "logD"]] .head(5) .round(2) .to_string(index=False) )
13.2 Operating regions of a pH process
The neutralization of a strong acid by a strong base in a stirred tank [80] is the standard example of a process whose gain depends on the operating point: around neutrality a small change of the base flow moves the pH by several units, far from it hardly at all. simulate_ph_cstr solves the component balances and the charge balance. Segmenting the record by its local dynamics with dynamic PCA (section 5.2, lag selected automatically) and fitting a first-order ARX model to every segment gives the local static gain and the pole of each operating region (fig. 13.3). The gains near pH 6.6 are an order of magnitude larger than at the extremes – the information a gain-scheduled controller needs.
seg = sg.DPCASegmenter(n_segments=8, lags="auto", n_components=0.99).segment(P) rows = [] for a, b in seg.segments: u, y = P[a:b, 0], P[a:b, 1] A = np.column_stack([y[:-1], u[:-1], np.ones(b - a - 1)]) (a1, b1, _), *_ = np.linalg.lstsq(A, y[1:], rcond=None) rows.append( { "start": a, "stop": b, "mean pH": y.mean(), "local gain": b1 / (1 - a1) if a1 < 1 else np.nan, "pole": a1, } ) print(pd.DataFrame(rows).round(3).to_string(index=False))
13.3 Explaining operating regimes
The last case study starts from a record of four process variables that switches among three regimes. A sticky HMM labels the regimes; a two-level decision tree describes them by the variables with a training accuracy of 0.98 (section 11.3); the transition network shows that every regime can follow every other; and the boundary contributions tell which variables moved at each switch (fig. 13.4). The rules are the part an operator keeps: they turn an unsupervised segmentation into a vocabulary of regimes that can be checked against experience and used in an operator support system, the purpose of the decision-tree analysis of Varga et al. [17].
ex = explain_states(X, seg, names=names, max_depth=2) print(f"training accuracy of the rules: {ex[’accuracy’]:.3f}") print(ex["rules"]) print(ex["importances"].round(3))
Open in ColabExample plot_03_regime_explanation.py in the gallery
13.4 A workflow
The case studies follow the same workflow, which is also a summary of the book. Look at the data and choose what homogeneity means: levels, correlation structure, dynamics, relations, shapes. Segment with a matching cost or model, inspect the merge hierarchy, and choose the number of segments with several rules and a stability check. Label recurring segments as states and compare series by warping their segment sequences or samples. Evaluate against whatever ground truth exists, and compare methods statistically. Explain the result by contributions, rules and transition networks. Operate it: write the configuration, save and register the model, monitor drift, document the model. Each step has a section of this book and a function of the package.
In a nutshell: Case studies
In a polymer grade campaign, state segmentation labels grades and transitions and Fisher-information segmentation shows that the transitions identify the kinetics. In a pH process, dynamic-PCA segmentation and local ARX models reveal the operating-point dependence of the gain. In a regime record, a sticky HMM, decision-tree rules, a transition network and boundary contributions make the regimes understandable. The common workflow: look, segment, label and compare, evaluate, explain, operate.