% MICROCRE teaching simulation: Assumed bilinear tensile response % NOT EXECUTED IN MATLAB/Octave in the authoring environment. % Python/SciPy counterpart has been run; see validation-report.json. % Standalone MATLAB R2016b+ script (local functions); no extra toolbox required. % Edit p below, run this file, inspect outputs and assumptions before use. % Formula: ε_y=σ_y/E;σ=Eε(ε≤ε_y),否则σ=σ_y+H_t(ε−ε_y);W_v=∫σdε % Assumption: 一维、单调拉伸、小应变教学近似;0≤H_t≤E。 % Assumption: 节点显式包含屈服转折点,以避免积分跨过转折的额外误差。 % Limitation: 不含颈缩、损伤、断裂、应变率及温度效应。 % Limitation: H_t是总应力—应变曲线切线,不直接等于以塑性应变定义的硬化模量。 % Source: https://ansyshelp.ansys.com/public/Views/Secured/corp/v252/en/lsdyna_ug/lsdyna_ug_matmodels_biisohard.html % This is not product performance, calibration, or compliance evidence. clear; close all; clc; p.modulus = 200; % 弹性模量 [GPa] p.yield_stress = 250; % 假设屈服应力 [MPa] p.tangent = 1000; % 屈服后切线模量 [MPa] p.max_strain = 2; % 最大工程应变 [%] assert(isfinite(p.modulus) && p.modulus>=0.001 && p.modulus<=2000, 'Invalid modulus'); assert(isfinite(p.yield_stress) && p.yield_stress>=0.001 && p.yield_stress<=10000, 'Invalid yield_stress'); assert(isfinite(p.tangent) && p.tangent>=0 && p.tangent<=1000000.0, 'Invalid tangent'); assert(isfinite(p.max_strain) && p.max_strain>=0.001 && p.max_strain<=20, 'Invalid max_strain'); E=p.modulus*1000; H=p.tangent; ey=p.yield_stress/E; em=p.max_strain/100; assert(H<=E,'Tangent modulus exceeds elastic modulus.'); strain=linspace(0,em,501); if eyey; stress(mask)=p.yield_stress+H*(strain(mask)-ey); lines=s('Assumed bilinear loading',100*strain,stress,'percent','MPa'); out=struct('yield_strain',100*ey,'max_stress',stress(end),'plastic_offset',100*max(0,em-stress(end)/E),'work_density',trapz(strain,stress)); outdir=fullfile(pwd,'tensile-response_results'); if ~exist(outdir,'dir'),mkdir(outdir);end fid=fopen(fullfile(outdir,'tensile-response.csv'),'w'); assert(fid>=0,'Cannot open CSV'); fprintf(fid,'series,x,y,x_unit,y_unit\n'); for j=1:numel(lines) for k=1:numel(lines(j).x) fprintf(fid,'"%s",%.17g,%.17g,"%s","%s"\n',lines(j).name,lines(j).x(k),lines(j).y(k),lines(j).xu,lines(j).yu); end end fclose(fid); fig=figure('Color','w');hold on; for j=1:numel(lines) if lines(j).plot,plot(lines(j).x,lines(j).y,'LineWidth',1.5,'DisplayName',lines(j).name);end end grid on;legend('show','Location','best');xlabel(lines(1).xu);ylabel(lines(1).yu); title('Assumed bilinear tensile response','Interpreter','none'); print(fig,fullfile(outdir,'tensile-response.png'),'-dpng','-r160'); fid=fopen(fullfile(outdir,'tensile-response-summary.json'),'w');fprintf(fid,'%s',jsonencode(struct('inputs',p,'outputs',out,'notice','Teaching model; not product validation.')));fclose(fid); disp(out); function a=s(name,x,y,xu,yu) a=struct('name',name,'x',x,'y',y,'xu',xu,'yu',yu,'plot',true); end function q=qlinear(values,p) v=sort(values); pos=p*(numel(v)-1); k=floor(pos)+1; f=pos-floor(pos); if k==numel(v),q=v(k);else,q=v(k)*(1-f)+v(k+1)*f;end end