clc clear all %参考四面体 %顶点1-[1,0,0] 2-[0,1,0] 3-[0,0,1] 4-[0,0,1] % 算例配置(改频率/材料/边界请编辑 case_config.m) [phy, cfg] = case_config(); %读取网格 load(cfg.meshMatFile); mesh.PECIndex=findIndex(phy.PEC,mesh); mesh.PBCIndex=findPBCIndex(phy.src,phy.dst,cfg.pbcWaveVec,mesh); mesh.PBCphi=cfg.pbcPhi; mesh.PBCIndex2=findPBCIndex(phy.src2,phy.dst2,cfg.pbcWaveVec2,mesh); mesh.PBCphi2=cfg.pbcPhi2; %矩阵组装 solver.Ai=[];solver.Aj=[];solver.Av=[]; solver.Bi=[];solver.Bj=[];solver.Bv=[]; solver=assembly_equ(phy,mesh,solver); solver.A=sparse(solver.Ai,solver.Aj,solver.Av); solver.B=sparse(solver.Bi,solver.Bj,solver.Bv); %Bloch boundary solver=assembly_pbc_double(mesh,solver); %求解 solver.A=solver.P'*solver.A*solver.P; solver.B=solver.P'*solver.B*solver.P; targetk0=2*pi/(phy.c_const/phy.ff0); sigma=targetk0*targetk0; numberSolve=cfg.NbrMode; [solver.x,GAMA_sq]=eigs(solver.A,solver.B,numberSolve,sigma); solverk0=diag(sqrt(GAMA_sq)); solverff0=phy.c_const./(2*pi./solverk0) %计算电场 nn=2;%第nn个模式 triIndex=findTri(9,mesh); [x,y,normE]=get_ele(triIndex,mesh,solver.P*solver.x(:,nn)); patch(x,y,normE,'EdgeAlpha',0) colormap jet; colorbar