可以使用 svenholcombe 开发的 MATLAB-LSDYNA 插件,该插件目前以开源的形式发布,在 Github 上的地址是:MATLAB-LSDYNA。
该插件可以直接读取 ASCII 结果文件,也可以在 MATLAB 中调用 LS-DYNA 求解器,需要注意的是,simulation.m 程序中 LSDYNA 求解器的路径位置是绝对路径的,如下:
properties (Constant, Hidden) dynaExe = 'C:\LSDYNA\program\LS-DYNA_smp_s_R610_winx64_ifort101.exe' end
使用的时候,需要修改绝对路径的位置。也可以将 LSDYNA 安装在 'C:\LSDYNA\' 下,这样就不用修改程序中的路径。
使用插件调用求解器:
S = lsdyna.simulation('C:\FolderToSim\mainFile.k') S.run
读取 ASCII 计算结果:
out = lsdyna.read.asciiFiles(folder) out = asciiFiles with properties: folder: 'C:\Folder\Holding\Simulation' rbdout: [1x1 lsdyna.read.rbdout] nodfor: [1x1 lsdyna.read.nodfor] bndout: [1x1 lsdyna.read.bndout] nodout: [1x1 lsdyna.read.nodout] elout: [1x1 lsdyna.read.elout]
顺序计算文件夹下的算例:
baseFolder = 'C:\FolderToSims'; for i = 1:10 simFolder = fullfile(baseFolder,sprintf('sim%d',i)); S(i) = lsdyna.simulation(fullfile(simFolder,'mainFile.k')); end S.run % Each simulation will be run, one after the other
多线程并行计算,同时计算 4 个算例:
baseFolder = 'C:\FolderToSims'; for i = 1:10 simFolder = fullfile(baseFolder,sprintf('sim%d',i)); S(i) = lsdyna.simulation(fullfile(simFolder,'mainFile.k')); S(i).cmdBlocking = false; end % Run simulations in parallel using 4 threads. The first 4 % simulations will start in a new command window, and when each is % complete, it will fire the next simulation to run in the available % thread. S.run('threads',4)
读取 LS-DYNA 的 K 文件
kFileStr = 'GHBMC_M50-O_v4-5_20160901.k'; [PART, NODE, ELEMENT_SHELL, ELEMENT_SOLID] = lsdyna.read.kfile(kFileStr); figure, plot3(NODE.x,NODE.y,NODE.z,'.'), axis image, view(3)