optframework.base.dpbe_adapter module
Created on Tue Aug 26 12:54:06 2025
@author: px2030
- class optframework.base.dpbe_adapter.DPBEAdapter(*, opt, role: Literal['main', 'NM', 'M'] = 'main', **kw: Any)[source]
Bases:
WriteThroughAdapter
Adapter for DPBESolver with role-aware handling.
- Roles:
“main”: 2D main solver; alpha_prim [a0, a1, a2] -> [a0, a1, a1, a2]
“NM” : 1D auxiliary solver; alpha_prim takes a0
- “M”1D auxiliary solver; alpha_prim takes a2
- For dim==2:
pl_P3 -> impl.pl_P1 (written immediately)
pl_P4 -> impl.pl_P2 (written immediately)
- set_comp_para(data_path: str) None [source]
Wrap component-parameter setup and write-through into solvers (opt.p, opt.p_NM, opt.p_M).
Parameters
- optobject
A coordinator object that holds optimizer-wide parameters and the solver instances: - opt.p : the main solver (may be a DPBEAdapter or a raw solver) - opt.p_NM : auxiliary solver for NM (dim==1) when opt.dim > 1 - opt.p_M : auxiliary solver for M (dim==1) when opt.dim > 1 - opt.dim : problem dimension (1 or 2) - opt.USE_PSD_R, opt.R01_0, opt.R03_0, opt.R01_0_scl, opt.R03_0_scl, etc.
- data_pathstr
opt path where PSD data folder resides (expects a subfolder ‘PSD_data’).
Returns
- bool
True on success. Also sets opt.set_comp_para_flag = True.
- calc_init_from_data(exp_data_paths, init_flag) None [source]
Initialize the number concentration N for PBE(s) based on experimental data.
This method initializes the N for both 1D and 2D PBE instances. For 2D PBE systems, the initialization assumes that the system initially contains only pure materials (i.e., no mixed particles have formed yet). As a result, the initialization of 2D PBE is effectively equivalent to performing two 1D initializations: one for the NM particles and one for the M particles.
Parameters
- sample_numint
The number of sets of experimental data used for initialization.
- exp_data_pathslist of str
Paths to the experimental data for initialization.
- init_flagstr
The method to use for initialization: ‘int’ for interpolation or ‘mean’ for averaging the initial sets.
- calc_delta_pop(x_uni_exp, data_exp) float [source]
Calculate the average differences (delta) between experimental and simulated PSDs.
This method loops through the experimental data and computes the average difference (delta) between the experimental PSD and the simulated PSD. It supports both single and multiple sample sets and handles optional smoothing via KDE (Kernel Density Estimation).
Parameters
- x_uni_exparray-like
The unique particle diameters in experimental data.
- data_exparray-like
The experimental PSD data that will be compared with the simulated PSD.
- pop:class:
An instance of the PBE solver, which generates the simulated PSD.
Returns
- float
The average difference (delta) between the experimental PSD and the simulated PSD, normalized by the number of particle sizes in the experimental data (x_uni_exp).
- generate_data(data_path=None, multi_flag=False, pop_params=None, add_info='')[source]
Generates synthetic data based on simulation results, with optional noise.
This method generates synthetic data based on the population parameters and simulation results. If noise is enabled, it modifies the file name to reflect the noise type and strength. The data is saved to an Excel file. For multi-dimensional optimizations, separate files for different dimensions are created.
Parameters
- pop_paramsdict, optional
Parameters for the population model. If not provided, uses self.pop_params.
- add_infostr, optional
Additional information to append to the file name. Default is an empty string.
Returns
None