fsi.bat
与fsi.sh
分别为windows与linux下的执行脚本,fsi.lsf
,fsi.pbs
,fsi.slurm
分别是几个作业调度系统LSF、PBS、Slurm的提交脚本。上述几个脚本在执行前需要根据自己的情况修改NPF(Fluent使用核数)、NPA(Mechanical使用核数),并行方式使用的是SharedAllocateMachines
,也即共用节点和核心,跨节点运行未考虑。变量FLUID与STRUCT同样要根据实际情况修改为是Solution 1还是Solution。文件夹Tutorial-Fluent-SC/Tutorial-CFX-SC提供了算例供试验。
下文为参照官方帮助文档ANSYS SystemCoupling2.0进行的总结,已发布至SunBlog,建议直接阅读官方ANSYS帮助文档。
System Coupling Data Model Settings
包含以下四个部分:CouplingControl
OutputControl
CouplingInterface
CouplingParticipant
- Create a directory structure.
- Set up the coupled analysis.
注:对于Fluent来说就是要设置一个或多个边界条件,并设置动网格,Calculate下面的时间步长和时间步数不起作用,会被SC中的设置覆盖;
对于Mechanical来说就是要设置一个System Coupling Region,并注意一些其他设置(
End Time Specification
、Ramping of Data-Transfer Loads
、Ramping of Loads Within Mechanical
、Output Controls
), - Generate participants' solver input files. 注意:Fluent中的input file需要在更新Workbench Solution之前 产生
- Export a System Coupling SCI file. 注意:在早前版本的Workbench下导出的SCI文件可能不含这一标签,这时就需要手动加入
- 准备一个耦合分析的目录结构
- 完成各个部件的设置 注:对于Fluent来说就是要设置一个或多个边界条件,并设置动网格,Calculate下面的时间步长和时间步数不起作用,会被SC中的设置覆盖; 对于Mechanical来说就是要设置一个System Coupling Region
- 额外的组件设置 包括:Compatible material properties、Compatible topological properties、Appropriate motion definitions
- 生成各组件文件,包括各组件的输入文件和scp文件
打开Shell,根据操作系统的不同执行以下命令:
"%AWP_ROOT195%\SystemCoupling\bin\systemcoupling"
"$AWP_ROOT195/SystemCoupling/bin/systemcoupling"
"%AWP_ROOT195%\SystemCoupling\bin\systemcoupling" --help
help(Initialize)
LoadParticipants(InputFiles = ["mechanical.scp", "fluent.scp"])
随后会输出scp文件中的信息: CouplingControl
、OutputControl
、CouplingParticipant
Tip:To load a single participant, you can use the AddParticipant
command.
运行命令AddInterface
以添加耦合交界面,This command allows you to create one interface at a time by specifying the internal object names of participants and regions to be to included in the interface.
Sample:
AddInterface(SideOneParticipantName = ["AEDT-1"], SideOneRegionNames = ["Volume5"], SideTwoParticipantName = ["MAPDL-2"], SideTwoRegionNames = ["FVIN_1"])
Tip: To specify participants and regions by object display names, use the AddInterfaceByDisplayName command.
To create a data transfer between the sides of an existing interface, run the AddDataTransfer
command.This command allows you to create a data transfer by specifying the interface, the target side of the transfer, and variables to be associated with each side of the interface. To create a two-way data transfer on an interface, you must run this command twice, once for each direction.
After creating data transfers, you can run the GetErrors
command to verify that no errors were introduced.
AddDataTransfer(Interface = "Interface-1",TargetSide = "Two",SideOneVariable = "Loss",SideTwoVariable = "HGEN")
运行
StartParticipants()
StartParticipants()
为可选参数,可以忽略此参数直接运行之后的Solve
Initialize
Step
等命令,软件会自动地启动各个组件(除非是在ExecutionControl
设置为ExternallyManaged
这种情况下,软件无法自动启动各个组件),不过StartParticipants()
可以提供更多的控制选项
运行
Solve()
求解开始后,耦合求解的输出会存到Transcript和Log File中
求解好后,可以查看分析输出文件并进行相应的后处理
耦合分析会自动存到两个HDF5文件里面,如果需要手动保存,可以使用Save
命令。默认情况下,上次完成的结果文件会保存到SyC
目录下面
- 在交互模式下,使用
Shutdown
命令来停止,这是一种干净的Shutdown,可以生成一个Restart point - 在命令行模式下,可以在System Coupling工作目录下面创建一个名为scStop的文件来Interrupt或者Aboort计算
Restart points可以以在以下几种情况下产生:
- 可以通过
outputControl
data model settings指定 - 通过
CreateRestartPoint
交互式命令指定 - 分析干净退出时
- 在System Coupling控制台,运行
open
命令,System Coupling会默认找到最新的coupling step,载入需要的数据并从该时间步重新开始 - 如果之前的分析已经求解完,可以通过使用
DurationControl
设置来延长分析 - 如果需要修改设置,可以在此时进行修改,在重启之前的设置都会写入到
Settings
文件并在下次重算时使用 - 使用你自己喜欢的求解过程(使用
Solve
命令或者是交互式的求解命令)
- 运行带有
CouplingStep
参数的open
命令(注意,当从一个较早的重算点重算时,这之后的重算点都会被删除,如果还要这些重算点,可以在不同的目录下面保存重算点文件和Settings文件) - 如果需要修改设置,可以在此时进行修改,在重启之前的设置都会写入到
Settings
文件并在下次重算时使用 - 使用你自己喜欢的求解过程(使用
Solve
命令或者是交互式的求解命令)
一些主要的交互式命令:
PrintSetup
Initialize
Step
CreateRestartPoint
Shutdown
- Set up your analysis
- (Optional) To start System Coupling in parallel mode, use the parallel-specific startup options
- Set up your coupled analysis
- Edit your data model settings.
- (Optional) To run a coupling participant in parallel mode, use the
ParallelArguments
ExecutionControl setting to specify details of the participant's execution Tip:Parallel arguments are not specified in the participant's SCP file and must be entered directly into the data model. - (Optional) Use the
PartitionParticipants
command to specify how the participants are partitioned across compute resources. For more information, see Using Parallel Processing Capabilities. - Run the solution.
"%AWP_ROOT195%\SystemCoupling\bin\systemcoupling" -t<NPROCS> [-p <INTERCONNECT>]
[--mpi=<MPI>] [-cnf=<HOSTFILE>]
$AWP_ROOT195/SystemCoupling/bin/systemcoupling" -t<NPROCS> [-p <INTERCONNECT>]
[--mpi=<MPI>] [-cnf=<HOSTFILE>]
PartitionParticipants(AlgorithmName = 'SharedAllocateMachines',NamesAndFractions = [('PARTICIPANT-1', 1.0), ('PARTICIPANT-2', 1.0),('PARTICIPANT-3', 1.0/5.0)]),MachineList = [{'M0' : 'host1', 'core-count' : 12},{'M1' : 'host2', 'core-count' : 12},{'M2' : 'host3', 'core-count' : 12},{'M3' : 'host4', 'core-count' : 7},{'M4' : 'host5', 'core-count' : 6},{'M5' : 'host6', 'core-count' : 3},{'M6' : 'host7', 'core-count' : 3},{'M7' : 'host8', 'core-count' : 1},{'M8' : 'host9', 'core-count' : 1}])
You can execute a command-line run of a coupled analysis that was set up in Workbench.The execution process is similar to that of an analysis to be run from the command line, except that you'll:
- populate the data model with a System Coupling SCI file instead of multiple SCP files, and
- set execution controls in the data model (because the SCI file doesn't provide this information).
Note:
- The use of both SCI and SCP files in the same analysis is not supported.
- Restarts are not supported if the default participant names (as assigned in the SCI file: Solution, Solution 1, etc.) have been changed.
To run your Workbench setup from the command line, perform the following steps:
- Start System Coupling as described in Using the System Coupling Command-Line Interface (CLI).
- Import the SCI file by running the
ImportSystemCouplingInputFile
.
ImportSystemCouplingInputFile(FilePath = 'scInput.sci')
- To provide information not included in the SCI file, edit each participant's ExecutionControl settings in the data model:
- Set
WorkingDirectory
to the participant's coupling working directory. - Set InitialInput to the name of the participant's solver input file. Example:Set execution controls for two participants
- Set
DatamodelRoot().CouplingParticipant['Solution'].ExecutionControl.InitialInput = 'structural.dat'
DatamodelRoot().CouplingParticipant['Solution'].ExecutionControl.WorkingDirectory = 'Struct'
DatamodelRoot().CouplingParticipant['Solution 1'].ExecutionControl.InitialInput = 'fluidFlow.cas'
DatamodelRoot().CouplingParticipant['Solution 1'].ExecutionControl.WorkingDirectory = 'Fluid'
- Run the coupled analysis as described in Running a Command-Line Coupled Analysis.
- If desired, restart the coupled analysis as described in Restarting a Command-Line Coupled Analysis Run. Do not reissue the ImportSystemCouplingInputFile command.
- End Time Specification
- Ramping of Data-Transfer Loads
- Ramping of Loads Within Mechanical
- Output Controls
本脚本是在Workbench图形界面中将各部件中设置好后,导出各部件相应的输入文件和sci
文件,再在命令行模式下进行计算。
首先打开System Coupling CLI
Windows:
"%AWP_ROOT195%\SystemCoupling\bin\systemcoupling"
Linux:
"$AWP_ROOT195/SystemCoupling/bin/systemcoupling"
# Import the SCI file
ImportSystemCouplingInputFile(FilePath = 'coupling.sci')
# To provide information not included in the SCI file, edit each participant's ExecutionControl settings in the data model:
DatamodelRoot().CouplingParticipant['Solution'].ExecutionControl.InitialInput = 'struct.dat'
DatamodelRoot().CouplingParticipant['Solution'].ExecutionControl.WorkingDirectory = 'Struct'
DatamodelRoot().CouplingParticipant['Solution 1'].ExecutionControl.WorkingDirectory = 'Fluid'
DatamodelRoot().CouplingParticipant['Solution 1'].ExecutionControl.InitialInput = 'fluidFlow.jou'
DatamodelRoot().CouplingParticipant['Solution 1'].ExecutionControl.InitialInput = 'fluidFlow.cas'
DatamodelRoot().CouplingParticipant['Solution 1'].ExecutionControl.AdditionalArguments = '-t 2 -mpi=intel'
# Parallel Settings
PartitionParticipants(AlgorithmName = 'SharedAllocateMachines',NamesAndFractions = [('Solution', 0.5),('Solution 1', 1.0)], MachineList = [{'machine-name' : 'DESKTOP-szj', 'core-count' : 2}])
# Starting the Participants
StartParticipants()
# Starting the Solution
Solve()
# Restart the Solution
Open(FilePath = 'WorkingDirectoryWithResults', CouplingStep = 6)
DatamodelRoot().CouplingControl.AnalysisType.DurationControl.EndTime = '15 [s]'
# 另外各个部件也要完成相应的时间延长设置,如Mechanical中将struct.dat中的time延长。
一些可选命令
DatamodelRoot().CouplingControl.PrintState()
DatamodelRoot().CouplingParticipant.GetChildNames()
DatamodelRoot().CouplingParticipant['Solution 1'].ExecutionControl.PrintState()
DatamodelRoot().OutputControl.Option = 'StepInterval'
DatamodelRoot().OutputControl.OutputFrequency = '50'
DatamodelRoot().CouplingControl.AnalysisType.DurationControl.EndTime = '10 [s]'
DatamodelRoot().CouplingControl.AnalysisType.StepControl.TimeStepSize = '1.0 [s]'
GetErrors()
GetErrorsXML()