Code covered by the BSD License  

Highlights from
WTS (formerly Leonov) + GUI

image thumbnail
from WTS (formerly Leonov) + GUI by Michael Wendlandt
Calculates stress vs. strain curves of plastically deformed glassy polymers. GUI available.

WTS_GUI(varargin)
function varargout = WTS_GUI(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @WTS_GUI_OpeningFcn, ...
                   'gui_OutputFcn',  @WTS_GUI_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

function WTS_GUI_OpeningFcn(hObject, ~, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);


function varargout = WTS_GUI_OutputFcn(~, ~, handles) 
varargout{1} = handles.output;

function pushbutton1_Callback(~, ~, handles)
%get input for WTS model from GUI
G=str2double(get(handles.G,'String'));
PR=str2double(get(handles.PR,'String'));
K=G*(2/3)*(1 + PR)/(1-2*PR);
GnH=str2double(get(handles.GnH,'String'));
a=str2double(get(handles.a,'String'));
b=str2double(get(handles.b,'String'));
A0=str2double(get(handles.A0,'String'));
H0=str2double(get(handles.H0,'String'))*1000;
start=str2double(get(handles.start,'String'));
ende=str2double(get(handles.ende,'String'));
strainint=[start ende];  
strainrate=str2double(get(handles.strainrate,'String'));
T=str2double(get(handles.T,'String'));
tol=str2double(get(handles.tol,'String'));

%check for sign errors
if strainrate*ende<0 
   error('Sign of strainrate and strain are different !') 
end

%calculate stress 
[T33,truestrain]=WTS(K,G,GnH,a,b,A0,H0,strainint,strainrate,T,tol);
if (get(handles.checkbox2,'Value') == get(handles.checkbox2,'Max'))
    truestrain=exp(2 * truestrain) - exp(-truestrain);
end

%plot results and setup graph
if (get(handles.checkbox1,'Value') == get(handles.checkbox1,'Max'))
    hold on;
else
    hold off;
end
plot(abs(truestrain),abs(T33),'k');
ylim=str2double(get(handles.ylim,'String'));
if ylim==0
    set(gca,'YLim',[0 inf])
else
    set(gca,'YLim',[0 abs(ylim)])
end

if (get(handles.checkbox2,'Value') == get(handles.checkbox2,'Max'))
    set(get(gca,'XLabel'),'String','|\lambda_z^2 - \lambda_z^-^1|')
    strainint=exp(2 .* strainint) - exp(-strainint);
else
    set(get(gca,'XLabel'),'String','absolute true axial strain |\epsilon_z|')
end
set(get(gca,'YLabel'),'String','absolute total true axial stress |\sigma| [MPa]')
set(gca,'XGrid','on')
set(gca,'YGrid','on')

% --- Executes during object creation, after setting all properties.
function G_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function G_Callback(~, ~, ~)

function PR_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function PR_Callback(~, ~, ~)

function GnH_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function GnH_Callback(~, ~, ~)

function a_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function a_Callback(~, ~, ~)

function b_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function b_Callback(~, ~, ~)

function A0_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function A0_Callback(~, ~, ~)

function H0_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function H0_Callback(~, ~, ~)

function start_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function start_Callback(~, ~, ~)

function ende_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function ende_Callback(~, ~, ~)

function strainrate_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function strainrate_Callback(~, ~, ~)

function T_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function T_Callback(~, ~, ~)

function ylim_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function ylim_Callback(~, ~, ~)

function tol_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function tol_Callback(~, ~, ~)
function figure1_ResizeFcn(~, ~, ~)
function checkbox1_Callback(~, ~, ~)
function checkbox2_Callback(~, ~, ~)

function Import_Callback(~, ~,handles)
[filename, pathname] = uigetfile( ...
	{'*.*','All Files (*.*)'}, ...
	'Select Data File');
% If "Cancel" is selected then return
if isequal([filename,pathname],[0,0])
	return
% Otherwise construct the fullfilename and Check and load 
% the file
else
	File = fullfile(pathname,filename);
    data = load(File,'ascii');
    if (get(handles.checkbox2,'Value') == get(handles.checkbox2,'Max'))
        data(:,1)=exp(2 * data(:,1)) - exp(-data(:,1));
        plot(data(:,1),data(:,2),'o');
    else
        plot(data(:,1),data(:,2),'o');
    end
end

% --------------------------------------------------------------------
function help_Callback(~, ~, ~)
open('Manual WTS.pdf')

Contact us at files@mathworks.com