XIAN-FEM-2026June/三维matlab代码/2023-2-端口激励问题(四面体网格)/exportFig45Fem4.m

40 lines
1.6 KiB
Matlab
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function exportFig45Fem4()
%EXPORTFIG45FEM4 导出 Et 与 Figure4/5 端口面 normE 图plotE2 方式)
rootDir = fileparts(mfilename('fullpath'));
outDir = fullfile(rootDir, 'OutFile_fem4');
load(fullfile(rootDir, 'MeshData2x.mat'), 'Mesh');
[Physic, Material, Port1Solver, Port2Solver] = configPhysicMaterialFem4();
Port1Mesh = GetBMesh(Mesh.Nodes, Mesh.Faces, Mesh.FacesIndex, Physic.Port1);
[Port1Solver, Port1Mesh] = BoundaryEigenMode(Port1Mesh, Physic, Material, Port1Solver);
Port1Solver = GetPowerCoef(Port1Solver, Port1Mesh, Material.murF, 1);
Port1Mesh.normal = [0; 0; -1];
Port2Mesh = GetBMesh(Mesh.Nodes, Mesh.Faces, Mesh.FacesIndex, Physic.Port2);
[Port2Solver, Port2Mesh] = BoundaryEigenMode(Port2Mesh, Physic, Material, Port2Solver);
Port2Mesh.normal = [0; 0; 1];
[Solver, Mesh] = FemMatrixAssembly(Physic, Material, Mesh, ...
Port1Mesh, Port1Solver, Port2Mesh, Port2Solver);
[~, ~, ~, normE_elem] = GetExEyEz2(1, Mesh.Nodes, Mesh.Elements, ...
Mesh.EdgesOfElements, Solver.Et);
fid = fopen(fullfile(outDir, 'X_real.txt'), 'w');
fprintf(fid, '%.16g\n', real(Solver.Et));
fclose(fid);
fid = fopen(fullfile(outDir, 'X_imag.txt'), 'w');
fprintf(fid, '%.16g\n', imag(Solver.Et));
fclose(fid);
In = plotE2(Mesh.Nodes, Port1Mesh.OldFaces, Mesh.AllFaces, ...
Mesh.FacesOfElements, normE_elem, 4, 0.5);
Out = plotE2(Mesh.Nodes, Port2Mesh.OldFaces, Mesh.AllFaces, ...
Mesh.FacesOfElements, normE_elem, 5, 0.5);
saveas(figure(4), fullfile(outDir, 'fig4_port_in_matlab.png'));
saveas(figure(5), fullfile(outDir, 'fig5_port_out_matlab.png'));
fprintf('MATLAB port max |E| in=%g out=%g\n', In, Out);
fprintf('Saved fig4/5 to %s\n', outDir);
end