科研 Skill
工程计算环境初始化
engineering-context-init
Sets up a Python session with engineering constants, Pint units, and plotting defaults. Use at the start of a calculation session.
SKILL.md
Engineering Context Initialization Helper
Purpose
Standardize engineering sessions with a consistent environment that includes:
- Standard physical constants
- Unit registry for dimensional analysis
- Common scientific computing libraries
- Default plotting configurations
- Precision settings for numerical calculations
This helper eliminates the need to repeatedly set up the same environment at the start of each engineering session, ensuring consistency and saving time.
Prerequisites
Requires numpy, pint, scipy, and matplotlib (pandas optional) to be installed in the
Python environment that will run init-script.py. Missing libraries are skipped gracefully.
What It Sets Up
Standard Constants
- g: Standard gravity (9.80665 m/s²)
- R: Universal gas constant (8.314462618 J/(mol·K))
- R_air: Specific gas constant for air (287.05 J/(kg·K))
- gamma_air: Specific heat ratio for air (1.4)
- P_atm: Standard atmospheric pressure (101325 Pa)
- T_std: Standard temperature (288.15 K / 15°C)
- rho_air_std: Standard air density (1.225 kg/m³)
- mu_air_std: Dynamic viscosity of air at standard conditions (1.789e-5 Pa·s)
- nu_air_std: Kinematic viscosity of air at standard conditions (1.460e-5 m²/s)
- c_light: Speed of light (299792458 m/s)
- sigma_sb: Stefan-Boltzmann constant (5.670374419e-8 W/(m²·K⁴))
Unit Registry (Pint)
- Configured pint UnitRegistry for dimensional analysis
- Support for unit conversions
- Unit-aware calculations
Common Imports
- NumPy: Array operations and mathematical functions
- SciPy: Scientific computing (optimize, integrate, interpolate, special functions)
- Matplotlib: Plotting and visualization
- Pandas: Data manipulation (optional, if available)
Default Plotting Style
- Figure size: 10x6 inches
- Grid enabled
- LaTeX-style font rendering (if available)
- Professional color schemes
Precision Settings
- NumPy print precision: 6 decimal places
- Print suppression for small values
- Consistent formatting across sessions
Usage
Quick Start
Run the initialization script at the start of your session, using the path to
init-script.py inside this skill's own directory (not a bare relative path, which only
works if your working directory happens to be the skill folder):
exec(open('<path-to-this-skill-dir>/init-script.py').read())
Or copy-paste the contents of init-script.py directly into your Python session.
Example 1: Basic Calculations with Units
# After running init-script.py
from pint import UnitRegistry
ureg = UnitRegistry()
# Define a pressure with units
pressure = 500 * ureg.kPa
print(f"Pressure: {pressure}")
print(f"Pressure in psi: {pressure.to('psi')}")
# Calculate ideal gas properties
T = 300 * ureg.kelvin
V = 2 * ureg.m**3
n = (pressure * V / (R * T)).to('mol')
print(f"Moles of gas: {n:.2f}")
Example 2: Atmospheric Calculations
# After running init-script.py
# Calculate density at altitude using standard constants
altitude = 5000 # meters
T = T_std - 0.0065 * altitude # Temperature lapse rate
P = P_atm * (T / T_std) ** (g / (0.0065 * R_air))
rho = P / (R_air * T)
print(f"At {altitude}m altitude:")
print(f"Temperature: {T:.2f} K ({T-273.15:.2f} °C)")
print(f"Pressure: {P:.2f} Pa ({P/1000:.2f} kPa)")
print(f"Density: {rho:.4f} kg/m³")
Example 3: Flow Calculations
# After running init-script.py
# Reynolds number calculation
velocity = 50 # m/s
length = 2 # m characteristic length
Re = velocity * length / nu_air_std
print(f"Reynolds number: {Re:.2e}")
if Re > 5e5:
print("Flow is turbulent")
else:
print("Flow is laminar")
Example 4: Quick Plotting
# After running init-script.py
import numpy as np
import matplotlib.pyplot as plt
# The plotting style is already configured
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
plt.figure()
plt.plot(x, y, linewidth=2)
plt.xlabel('x [rad]')
plt.ylabel('sin(x)')
plt.title('Example Plot with Pre-configured Style')
plt.show()
Example 5: Unit Conversions
# After running init-script.py
# Power calculation with unit conversions
force = 1000 * ureg.N
velocity = 30 * ureg.m / ureg.s
power = (force * velocity).to('kW')
print(f"Power: {power}")
print(f"Power in hp: {power.to('hp'):.2f}")
print(f"Power in BTU/hr: {power.to('BTU/hr'):.2f}")
Files Included
- SKILL.md: This documentation file
- init-script.py: Complete initialization script ready to run
- constants.md: Reference list of all constants and their values
Limitations
init-script.pyis meant to beexec'd or copy-pasted into a live Python session (e.g. a notebook or REPL); it is not a standalone CLI tool and produces no output file.- All constants are for standard sea-level air; they are not valid for other fluids or non-standard conditions.
Notes
- The script checks for library availability and imports only what's available
- If matplotlib is not available, plotting configuration is skipped
- If pandas is not available, it's simply not imported (optional)
- All constants use SI units unless otherwise specified
- The pint UnitRegistry is created as
uregfor unit-aware calculations
Customization
You can modify init-script.py to:
- Add domain-specific constants
- Change default plotting styles
- Adjust precision settings
- Include additional library imports
- Set up custom unit definitions in pint
Best Practices
- Run the initialization at the start of each new engineering session
- Keep the script updated with your most commonly used constants
- Document any custom constants you add
- Use the unit registry for all calculations involving physical quantities
- Store the script in your project directory for easy access
示例提示词
帮我初始化一个带常用常数、单位和库导入的工程计算环境。
所属插件
安装该插件会一并获得同领域的 36 个 Skill / MCP。
同插件的其他科研 Skill
- ANSYS Fluent CFD仿真自动化Automates ANSYS Fluent CFD setup, meshing, and batch runs via Python scripting, journal files, and the PyAnsys ecosystem. Use when a user wants to script or automate an ANSYS Fluent simulation.
- Cantera燃烧仿真Runs Cantera combustion simulations: flame temperature, ignition delay, laminar flame speed, PSR. Use for mechanism-based combustion analysis tasks.
- 离心泵气蚀风险评估Calculates NPSHa and NPSHr and assesses cavitation risk for centrifugal pumps, with prevention and detection guidance. Use when sizing suction piping or diagnosing pump cavitation.
- 气蚀评估物性数据库Looks up vapor pressure, NPSHr data, and correlations for cavitation risk assessment in pumps. Use when cavitation-analysis needs reference property or NPSHr data.
- 离心泵设计计算Designs centrifugal pumps from first principles using Euler equations, velocity triangles, and specific speed. Use for impeller sizing or new centrifugal pump design.
- COMSOL多物理场耦合仿真Sets up coupled fluid-structure interaction simulations in COMSOL Multiphysics, focused on pump vibration analysis. Use when a user wants to script or automate a COMSOL FSI model.
- CoolProp流体物性查询Queries thermodynamic and transport properties for 100+ pure and pseudo-pure fluids via the CoolProp library. Use when a calculation needs fluid density, viscosity, or enthalpy data.
- 流体计算数值错误校验Handles common numerical errors in fluid calculations, such as division by zero and out-of-range physical values, with validation checks. Use when fluid code fails or returns unphysical results.
- 流体力学分析工作流Guides a systematic fluid dynamics analysis from problem setup and domain definition through model selection to validation. Use when planning a CFD or analytical fluid mechanics study end to end.
- 经验公式流体物性速算Computes quick fluid property estimates (density, viscosity, vapor pressure) from empirical correlations without needing a database. Use for fast order-of-magnitude property checks.
- 管道流动与泵选型计算Computes pipe flow, pump sizing, friction factor, and compressible flow results with the fluids Python package. Use for quick, code-based fluid mechanics calculations.
- 工程工具与数据库清点Enumerates installed Python packages, databases, and simulation tools available in the current environment. Use at the start of a session to avoid recommending unavailable tools.
- 管路元件损失系数查询Looks up loss coefficients (K-values) and equivalent lengths for pipes, valves, and fittings in pump and piping systems. Use when computing system head loss.
- 流体与材料物性查询Looks up temperature-dependent fluid viscosities, densities, and other material properties for pump and heat-transfer calculations. Use when a calculation needs property data at a given temperature.
- 泵性能曲线绘制Creates professional engineering plots such as pump performance curves, CFD velocity contours, and publication-quality figures with matplotlib. Use when a result needs a plotted figure.
- NASA大气与航空流体数据Accesses atmospheric property profiles and standard-atmosphere models from NASA Earthdata for high-altitude and aerospace fluid analysis. Use when a task needs altitude-dependent atmospheric data.
- 管网图论建模Models hydraulic piping networks and multi-pump systems as graphs using NetworkX flow algorithms. Use for analyzing flow distribution across a branched or looped piping network.
- REFPROP高精度物性查询Queries high-accuracy thermodynamic and transport properties from the commercial NIST REFPROP database. Use when a calculation needs reference-quality fluid property data and REFPROP is licensed.
- 数值数组计算Performs numerical array operations with NumPy: velocity field processing, pump curve interpolation, linear systems, and matrix methods. Use for general numerical computation in engineering code.
- OpenFOAM仿真与后处理Runs and post-processes OpenFOAM CFD simulations with PyFoam, pyvista, and vtk for mesh setup, solver control, and visualization. Use for scripted OpenFOAM workflows outside ParaView.
- 泵性能曲线与相似定律Generates and interprets pump H-Q/efficiency/power/NPSH curves, applies affinity laws, and predicts off-design performance. Use for pump curve analysis.
- 工程单位换算与量纲分析Handles engineering units with automatic conversion and dimensional-consistency checking using the Pint library. Use whenever a calculation mixes units or needs unit safety.
- 容积式泵设计分析Designs and analyzes gear, piston, and screw positive-displacement pumps, including volumetric efficiency and slip. Use when the pump is positive-displacement rather than centrifugal.
- 泵效率优化Maximizes pump efficiency through hydraulic design changes and operational strategies such as trimming, VFD control, and system matching. Use when a pump is running inefficiently.
常见问题
工程计算环境初始化能做什么?
Sets up a Python session with engineering constants, Pint units, and plotting defaults. Use at the start of a calculation session。
如何安装工程计算环境初始化?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「工程计算环境初始化」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
工程计算环境初始化需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
工程计算环境初始化经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。