% MICROCRE teaching simulation: Three-point bending deflection % 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: I=bh³/12;w(x)=Fx(3L²−4x²)/(48EI),0≤x≤L/2,另一半镜像;w_max=FL³/(48EI) % Assumption: 均匀线弹性细长梁、小挠度、理想简支和中央点载荷。 % Limitation: 不含剪切变形、支点压陷、塑性或大挠度。 % Limitation: 未输入屈服应力,因此不能判定载荷是否安全。 % Source: https://www.purdue.edu/freeform/me323/wp-content/uploads/sites/2/2024/02/ME-323-Craig-Superposition-Tables.pdf % This is not product performance, calibration, or compliance evidence. clear; close all; clc; p.force = 100; % 中央载荷 [N] p.length = 100; % 跨距 L [mm] p.width = 10; % 宽度 b [mm] p.height = 5; % 厚度 h [mm] p.modulus = 200; % 杨氏模量 E [GPa] assert(isfinite(p.force) && p.force>=0 && p.force<=1000000.0, 'Invalid force'); assert(isfinite(p.length) && p.length>=1 && p.length<=10000.0, 'Invalid length'); assert(isfinite(p.width) && p.width>=0.1 && p.width<=1000, 'Invalid width'); assert(isfinite(p.height) && p.height>=0.1 && p.height<=1000, 'Invalid height'); assert(isfinite(p.modulus) && p.modulus>=0.001 && p.modulus<=2000, 'Invalid modulus'); x=linspace(0,p.length,401); a=min(x,p.length-x); I=p.width*p.height^3/12; E=p.modulus*1000; y=p.force*a.*(3*p.length^2-4*a.^2)/(48*E*I); lines=s('Downward deflection',x,y,'mm','mm'); out=struct('max_deflection',p.force*p.length^3/(48*E*I),'max_stress',3*p.force*p.length/(2*p.width*p.height^2),'second_moment',I); outdir=fullfile(pwd,'beam-bending_results'); if ~exist(outdir,'dir'),mkdir(outdir);end fid=fopen(fullfile(outdir,'beam-bending.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('Three-point bending deflection','Interpreter','none'); print(fig,fullfile(outdir,'beam-bending.png'),'-dpng','-r160'); fid=fopen(fullfile(outdir,'beam-bending-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