% EXAMPLE SCRIPT FOR RUNNING SPACAR LIGHT % This example simulates a simple cross flexure rotating due to an applied moment clear clc close all % addpath('spacar') %Specify location of spacar folder, if not current %% NODE POSITIONS % x y z nodes = [ 0 0 0; %node 1 0 -0.02 0; %node 2 0 -0.04 0; %node 3 0 -0.06 0]; %node 4 %% ELEMENT CONNECTIVITY % p q elements = [ 1 2; %element 1 2 3; %element 2 3 4]; %element 3 %% NODE PROPERTIES %node 1 nprops(1).fix = true; %Fix node 1 nprops(3).force = [1 0 0]; %% ELEMENT PROPERTIES eprops(1).elems = [1]; %Add this set of properties to elements 1 and 3 eprops(1).emod = 2e9; %E-modulus [Pa] eprops(1).smod = 68.9e6; %G-modulus [Pa] eprops(1).dens = 1150; %Density [kg/m^3] eprops(1).cshape = 'rect'; %Rectangular cross-section eprops(1).dim = [5e-3 1e-3]; %Width: 50 mm, thickness: 0.2 mm eprops(1).orien = [0 0 1]; %Orientation of the cross-section as a vector pointing along "width-direction" eprops(1).nbeams = 1; %Number of beams used to model this element eprops(1).flex = 1:6; %Model out-of-plane bending (modes 3 and 4) as flexible eprops(1).color = 'grey'; %Color eprops(2).elems = [2 3]; %Add this set of properties to elements 1 and 3 eprops(2).emod = 2e9; %E-modulus [Pa] eprops(2).smod = 68.9e6; %G-modulus [Pa] eprops(2).dens = 1150; %Density [kg/m^3] eprops(2).cshape = 'rect'; %Rectangular cross-section eprops(2).dim = [5e-3 5e-3]; %Width: 50 mm, thickness: 0.2 mm eprops(2).orien = [0 0 1]; %Orientation of the cross-section as a vector pointing along "width-direction" eprops(2).nbeams = 1; %Number of beams used to model this element eprops(2).flex = 1:6; %Model out-of-plane bending (modes 3 and 4) as flexible eprops(2).color = 'grey'; %Color %% OPTIONAL ARGUMENTS opt.filename = 'contact'; %Filename opt.loadsteps = 20; opt.customdyn = {'usersig PUSHSIG'}; %Unfortunately, this is case-sensitive ... %% CALL SPACAR_LIGHT out = spacarlight(nodes, elements, nprops, eprops, opt); pos = out.node(4).p(1,:); figure plot(pos)