用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Soljourner/claude-engineering-skills --skill comsol-multiphysics命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | comsol-multiphysics |
| description | Set up coupled fluid-structure interaction for pump vibration analysis |
| category | integrations |
| domain | multiphysics |
| complexity | advanced |
| dependencies | [] |
Comprehensive guide for setting up and automating coupled fluid-structure interaction (FSI) simulations using COMSOL Multiphysics, with a focus on pump vibration analysis and related multiphysics applications.
COMSOL Multiphysics is a leading commercial simulation platform for modeling and solving complex multiphysics problems. It provides:
COMSOL excels at coupled physics problems including:
COMSOL Multiphysics requires commercial licenses for all production use:
Base Package:
Module Licenses:
License Server Setup:
# Set license server environment variable (Linux/Mac)
export LMCOMSOL_LICENSE_FILE=1718@license-server.company.com
# Or in Windows
set LMCOMSOL_LICENSE_FILE=1718@license-server.company.com
License Types:
Comprehensive computational fluid dynamics for single-phase and multiphase flows:
Capabilities:
Turbulence Models:
Flow Types:
Multiphase Flow:
Pump-Specific Features:
Comprehensive structural analysis including linear and nonlinear behavior:
Capabilities:
Analysis Types:
Material Models:
Dynamic Analysis:
Pump-Specific Features:
Couples CFD and Structural Mechanics for two-way interaction:
Coupling Approaches:
One-Way FSI:
Two-Way FSI:
Weak Coupling:
Strong Coupling:
FSI Features:
Pump FSI Applications:
Acoustics Module:
Heat Transfer Module:
Optimization Module:
COMSOL provides a comprehensive Java API for programmatic model building and automation:
Core Components:
import com.comsol.model.*;
import com.comsol.model.util.*;
public class PumpFSI {
public static Model run() {
// Create model
Model model = ModelUtil.create("PumpFSI");
// Create component
model.component().create("comp1", true);
// Create geometry
model.component("comp1").geom().create("geom1", 3);
// Import CAD geometry
model.component("comp1").geom("geom1").create("imp1", "Import");
model.component("comp1").geom("geom1").feature("imp1")
.set("filename", "/path/to/pump_geometry.step");
model.component("comp1").geom("geom1").run();
// Add fluid physics (CFD)
model.component("comp1").physics().create("spf", "LaminarFlow", "geom1");
model.component("comp1").physics("spf").selection()
.named("geom1_fluid_domain");
// Add structural physics
model.component("comp1").physics().create("solid", "SolidMechanics", "geom1");
model.component().physics().selection()
.named();
model.component().multiphysics().create(, , );
model.component().multiphysics()
.selection().named();
model.component().mesh().create();
model.component().mesh().automatic();
model.component().mesh().run();
model.study().create();
model.study().create(, );
model.study().feature().set(, );
model.sol().create();
model.sol().study();
model.sol().feature().create(, );
model.sol().feature().create(, );
model.sol().feature().create(, );
model.sol().attach();
model.sol().runAll();
model.save();
model;
}
{
run();
}
}
# Compile Java file
comsol compile PumpFSI.java
# Run with COMSOL
comsol batch -inputfile PumpFSI.class -outputfile results.mph
# Or run directly
java -cp /path/to/comsol/plugins/*:. PumpFSI
COMSOL integrates seamlessly with MATLAB for enhanced scripting and data processing:
Model Control from MATLAB:
Installation:
% Initialize COMSOL with MATLAB
import com.comsol.model.*
import com.comsol.model.util.*
% Start COMSOL server (if not already running)
mphstart
% Create or load model
model = mphload('pump_model.mph');
% Modify parameters
model.param.set('inlet_velocity', '5[m/s]');
model.param.set('outlet_pressure', '101325[Pa]');
% Run study
model.study('std1').run();
% Extract results
pressure = mpheval(model, 'p', 'dataset', 'dset1');
velocity = mpheval(model, 'u', 'dataset', 'dset1');
% Process in MATLAB
mean_pressure = mean(pressure.d1);
max_velocity = max(sqrt(velocity.d1.^2 + velocity.d2.^2 + velocity.d3.^2));
% Plot using MATLAB
figure;
plot(pressure.p, pressure.d1);
xlabel('Position');
ylabel('Pressure [Pa]');
title('Pressure Distribution');
% Save results
save('pump_results.mat', 'pressure', 'velocity');
% Close COMSOL
ModelUtil.remove('model');
% Parametric study of inlet velocity effects
velocities = 1:1:10; % m/s
results = struct();
for i = 1:length(velocities)
fprintf('Running case %d: velocity = %.1f m/s\n', i, velocities(i));
% Set parameter
model.param.set('inlet_velocity', sprintf('%f[m/s]', velocities(i)));
% Solve
model.study('std1').run();
% Extract force on impeller
force = mphint2(model, 'spf.Fp_x', 'surface', 'selection', 5);
results(i).velocity = velocities(i);
results(i).force = force;
% Extract vibration amplitude
displacement = mphmax(model, 'sqrt(u^2+v^2+w^2)', 'volume', 'selection', 3);
results(i).max_displacement = displacement;
end
% Plot results
figure;
subplot(2,1,1);
plot([results.velocity], [results.force], '-o');
xlabel('Inlet Velocity [m/s]');
ylabel('Force on Impeller [N]');
grid on;
subplot(2,1,2);
plot([results.velocity], [results.max_displacement]*1e6, '-o');
xlabel('Inlet Velocity [m/s]');
ylabel('Max Displacement [μm]');
grid on;
% Save results
save('parametric_results.mat', 'results');
Application: Analyze vibration of pump casing due to pressure pulsations from fluid flow.
Approach: One-way FSI (fluid loads mapped to structure)
Steps:
Geometry Setup:
CFD Setup:
Structural Setup:
FSI Coupling:
Solution:
Post-Processing:
Application: Coupled analysis of impeller blade deformation under fluid forces.
Approach: Two-way FSI with moving mesh
Steps:
Geometry and Mesh:
Fluid Physics:
Structural Physics:
Two-Way FSI Coupling:
Prestressed FSI:
Solution Strategy:
Post-Processing:
Application: Thermal effects in pumps handling hot fluids.
Approach: Conjugate heat transfer with thermal expansion
Steps:
Multi-Domain Setup:
Coupled Physics:
Boundary Conditions:
Material Properties:
Solution Sequence:
Post-Processing:
Application: Natural frequencies of pump casing in contact with fluid.
Approach: Eigenfrequency analysis with fluid-structure coupling
Steps:
Geometry:
Physics Setup:
Boundary Conditions:
Study:
Results:
COMSOL can run in batch mode without GUI:
# Run existing model file
comsol batch -inputfile pump_model.mph -outputfile results.mph
# Run Java method file
comsol batch -inputfile PumpFSI.java -outputfile results.mph
# Run with specific study
comsol batch -inputfile pump_model.mph -outputfile results.mph -study std1
# Run with parameter override
comsol batch -inputfile pump_model.mph -outputfile results.mph \
-pname inlet_velocity -plist 5,10,15,20
# Run MATLAB script
comsol batch -inputfile pump_analysis.m -outputfile results.mph
# Specify number of processors
comsol batch -np 8 -inputfile pump_model.mph -outputfile results.mph
#!/bin/bash
# batch_comsol.sh
# Set license server
export LMCOMSOL_LICENSE_FILE=1718@license-server.com
# Set number of processors
NPROCS=8
# Input/output files
INPUT_MODEL="pump_fsi_base.mph"
OUTPUT_DIR="results"
# Create output directory
mkdir -p ${OUTPUT_DIR}
# Parameter sweep: inlet velocities
VELOCITIES="2 4 6 8 10"
for VEL in ${VELOCITIES}; do
echo "Running simulation with inlet velocity = ${VEL} m/s"
OUTPUT_FILE="${OUTPUT_DIR}/pump_fsi_v${VEL}.mph"
LOG_FILE="${OUTPUT_DIR}/pump_fsi_v${VEL}.log"
# Run COMSOL in batch mode
comsol batch -np ${NPROCS} \
-inputfile ${INPUT_MODEL} \
-outputfile ${OUTPUT_FILE} \
-pname inlet_velocity \
-plist ${VEL} \
> ${LOG_FILE} 2>&1
# Check exit status
if [ $? -eq 0 ]; then
echo " Simulation completed successfully"
else
echo " ERROR: Simulation failed - check ${LOG_FILE}"
exit 1
fi
done
echo "All simulations completed"
Use JPype to call COMSOL Java API from Python:
import jpype
import jpype.imports
from jpype.types import *
import numpy as np
# Start JVM with COMSOL
comsol_root = '/usr/local/comsol56/multiphysics'
jvm_path = jpype.getDefaultJVMPath()
jpype.startJVM(
jvm_path,
f"-Djava.library.path={comsol_root}/lib/glnxa64",
f"-Dcs.lic.path={comsol_root}/license",
classpath=f"{comsol_root}/plugins/*"
)
# Import COMSOL packages
from com.comsol.model.util import ModelUtil
# Load model
model = ModelUtil.load('/path/to/pump_model.mph')
# Parametric study
velocities = np.linspace(2, 10, 5)
results = []
for vel in velocities:
print(f"Running velocity = {vel:.1f} m/s")
# Set parameter
model.param().set('inlet_velocity', f'{vel}[m/s]')
# Run study
model.study('std1').run()
# Extract results (example)
# Add actual result extraction here
# Save case
model.save(f'results/pump_v{vel:.1f}.mph')
results.append({
'velocity': vel,
# Add extracted results here
})
# Cleanup
ModelUtil.remove('model')
jpype.shutdownJVM()
()
Licensing Problems:
Meshing Failures:
Convergence Issues:
FSI-Specific Issues:
Performance Issues: