Initialization & Cleanup
pl_reset
Resets the PanLink engine for a new simulation session. This initializes internal states and prepares the specified module.
numThreads: Pointer to an integer specifying the number of threads to use (e.g., for OpenMP).
type: The module type to initialize (PL_MODULE_TYPE_PanPhaseEquilibrium, PL_MODULE_TYPE_PanEvolution, or PL_MODULE_TYPE_PanSoldification).
pl_free_PanLink
Frees all memory allocated by PanLink and shuts down the engine. Should be called when the simulation is complete.
Configuration
pl_set_db_folder
Sets the base directory where database files (.tdb, .kdb, etc.) are located. This must be called before running calculations.
path: Absolute or relative path to the database folder.
error_msg: Buffer to store any error messages if the operation fails.
Returns: true if successful, false otherwise.
pl_set_max_dt
Sets the maximum time step allowed for the simulation. If max_dt <= 0, the engine uses its adaptive time stepping.
max_dt: Pointer to the maximum time step value (in seconds).
pl_set_num_clusters
Sets the number of clusters for precipitation simulations. Default is typically 100.
num_clusters: Pointer to the integer value.
pl_set_output_properties
Enables or disables the calculation/output of specific predefined properties.
status: Array of PanLink_Predefined_Property_Status structures defining which properties to toggle.
count: The number of elements in the status array.
PROP_ID_CUSTOM cannot be managed here.
Calculation
pl_update_material_property
The core function to perform a calculation step. It takes the current state (time, temperature, composition) and updates the material properties.
thread_id: Pointer to the current thread ID (0-indexed).
cell_id: Pointer to the unique ID of the simulation cell/node.
variable: Pointer to the PanLink_State_Variable struct containing inputs (T, t, composition, etc.).
props: Pointer to the PanLink_Property struct where results will be stored.
error_msg: Buffer to store error messages on failure.
Returns: true if the update was successful, false otherwise.
PL_UPDATE_MATERIAL_PROPERTY
Alias for pl_update_material_property (uppercase convention).
Information
pl_get_system_info
Retrieves information about the currently loaded material system, including components and databases.
info: Pointer to a Material_System_Info struct to be populated.
Returns: true if successful.