%washing machine model
%
% LAST UPDATED by Andy French Jan 2019

function washing

%Define gravitational field strength, coefficient fo friction, 
%drum radius /m
g = 9.81;
mu = tan(30*pi/180);
r = 0.3;

%Number of graph points and graph font size
N = 500;
fsize = 18;

%Define angle of washing from vertical
theta = linspace(0,2*pi,N);

%Calculate omega for no slip
w = sqrt( (g/(mu*r))*( sin(theta) - mu*cos( theta ) ) );
wmax = sqrt( g/(mu*r) ) * ( ( 1 + mu^2 )^(1/4) );

%Calculate omega to maintain contact at all angles
wcontact = sqrt(g/r);

%Plot graph of w vs theta
plot( theta*180/pi, w*60/(2*pi) );
hold on
plot( [0, 360], (60/(2*pi))*[wmax,wmax],'k-' );
plot( [0, 360], (60/(2*pi))*[wcontact,wcontact],'r-' );
xlabel('\theta /deg','fontsize',fsize)
ylabel('\omega /RPM','fontsize',fsize)
set(gca,'fontsize',fsize)
grid on
title({'Washing machine angular speed for no slip',...
    ['For no slip \omega>',num2str((60/(2*pi))*wmax,3),...
    'RPM, for contact, ',num2str((60/(2*pi))*wcontact,3),'RPM']},'fontsize',fsize)
xlim([0,360]);
print( gcf, 'washing.png','-r300','-dpng' );
close(gcf)

%End of code