The core submodule
Factory and registry entry points for fluidsolve objects.
This module centralizes object creation and naming for components, working points, paths, and networks. Direct class construction is still possible, but using the factory helpers is recommended because they enforce consistent defaults and unique names.
Main responsibilities:
initialize module-wide defaults (prefixes, default medium/material),
create and register components through builder helpers,
create working points, paths, and networks with consistent naming,
expose lookup helpers for already-created objects.
Why this matters:
Several parts of the toolkit rely on stable object naming and centralized defaults. Bypassing the factories can lead to duplicate names or mismatched default conditions, which may affect downstream network and plotting tools.
Typical usage:
initFluidsolve(prefix_comp='Comp_', prefix_wpt='Wp_')
pump = getComp(comp='PumpCentrifugal', dataQH=curve, speed0=2900)
tube = getComp(comp='Tube', L=100, D=50)
Registry internals:
components, paths, networks, and working points are kept in module-level dictionaries,
helper getters return existing objects by name,
auto-index counters generate deterministic names when explicit names are not provided.
Naming/default policy:
prefixes are configurable through
initFluidsolve,default medium and material are configured once and reused by factories,
this ensures consistent assumptions across independently created objects.
Typical end-to-end flow:
initFluidsolve(default_medium='water')
p1 = getComp(comp='PumpCentrifugal', dataQH=curve, speed0=2900)
r1 = getComp(comp='Tube', L=120, D=50)
net = getNetwork(name='N1', components=[
{'nodes': ['A', 'B'], 'comp': p1},
{'nodes': ['B', 'A'], 'comp': r1},
])
result = net.calcNetwork(1.0)
The goal of this module is to keep model construction concise and reproducible, while avoiding duplicated setup logic in scripts and examples.
- fluidsolve.core.initFluidsolve(**kwargs: int) None[source]
Initialize module-wide defaults used by the factory helpers.
- fluidsolve.core.registerComp(name: str, comp: Comp_Base, raiseerror: bool = True) bool[source]
Register one component class in the component catalogue.
- Parameters:
name (str) – Key used by getComp.
comp (flsb.Comp_Base) – Component class to register.
raiseerror (bool, optional) – Raise on duplicate key.
- Returns:
True if registration succeeded, False otherwise.
- Return type:
bool
- fluidsolve.core.registerComps(comps: dict, raiseerror: bool = True) bool[source]
Register multiple component classes.
- Parameters:
comps (dict) – Mapping of component keys to component classes.
raiseerror (bool, optional) – Raise on duplicate keys.
- Returns:
True if all registrations succeeded, False otherwise.
- Return type:
bool
- fluidsolve.core.registerAllComps(raiseerror: bool = True) bool[source]
Register all built-in component classes.
- Parameters:
raiseerror (bool, optional) – Raise on duplicate keys.
- Returns:
True if all registrations succeeded, False otherwise.
- Return type:
bool
- fluidsolve.core.getDefaultMedium() Medium[source]
Return the current default medium.
- Returns:
Default medium.
- Return type:
flsme.Medium
- fluidsolve.core.setDefaultMedium(value: Medium) None[source]
Set the default medium.
- Parameters:
value (flsme.Medium) – Default medium.
- fluidsolve.core.getDefaultMaterial() Material[source]
Return the current default material.
- Returns:
Default material.
- Return type:
flsma.Material
- fluidsolve.core.setDefaultMaterial(value: Material) None[source]
Set the default material.
- Parameters:
value (flsma.Material) – Default material.
- fluidsolve.core.getComp(**kwargs: Any) Comp_Base[source]
Build and return a component instance from the registry.
- Parameters:
comp (str) – Component key in the internal registry.
kwargs – Arguments passed to the component constructor.
- Returns:
Instance of the requested component class.
- Return type:
flsb.Comp_Base
- fluidsolve.core.getWpt(**kwargs: Any) Wpoint[source]
Build and return a workingpoint instance.
- Parameters:
kwargs – Arguments passed to the workingpoint constructor.
- Returns:
Instance of the requested workingpoint class.
- Return type:
flswp.Wpoint
- fluidsolve.core.getPath(**kwargs: Any) Path[source]
Build and return a path object.
- Parameters:
kwargs – Arguments passed to the path constructor.
- Returns:
New path instance.
- Return type:
flspath.Path
- fluidsolve.core.getNetwork(**kwargs: Any) Network[source]
Build and return a network object.
- Parameters:
kwargs – Arguments passed to the network constructor.
- Returns:
New network instance.
- Return type:
flsnet.Network