-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbungee_initialLengthSolve.m
More file actions
executable file
·113 lines (65 loc) · 3.03 KB
/
bungee_initialLengthSolve.m
File metadata and controls
executable file
·113 lines (65 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
function [solutions] = bungee_initialLengthSolve(valuesMap)
% disp('DEBUG: initialLengthSolve');
% each row represents a list of dependancies that is sufficient to solve for the value
deplist = ...
{{'equilibriumLength', 'area', 'cordMass', 'jumperMass', 'paramK', 'paramN', 'modulus'}; ...
{'maxVelocity', 'area', 'cordMass', 'jumperMass', 'paramK', 'paramN', 'modulus'}; ...
{'maxLength', 'area', 'jumperMass', 'paramK', 'paramN', 'modulus'} ...
};
solutions = [];
% if no nan's in the first dependancy list
nancheck = cellfun(@(x) any(isnan(valuesMap(x))), deplist{1}, 'un', 0);
if max(cell2mat(nancheck)) == 0
% disp('DEBUG: initialLengthSolve Solution1');
% L_e=L_0 ( mg/EA+K(mg/EA)^n+1)
weight = 9.81 * ( valuesMap('jumperMass') + valuesMap('cordMass') );
areaModulusProduct = valuesMap('area') * valuesMap('modulus');
equilibriumLength = valuesMap('equilibriumLength');
k = valuesMap('paramK');
n = valuesMap('paramN');
solution_1 = equilibriumLength / ( (weight/areaModulusProduct) + k*(weight/areaModulusProduct).^n + 1 );
solutions = [solutions solution_1];
end
nancheck = cellfun(@(x) any(isnan(valuesMap(x))), deplist{2}, 'un', 0);
if max(cell2mat(nancheck)) == 0
% disp('DEBUG: initialLengthSolve Solution2');
% ?v_(max )= v?_e= v(2C_e gL_0cm- (2AL_0)/m ?_0^(C_e-1)¦?s de?)
maxVelocity = valuesMap('maxVelocity');
jumperMass = valuesMap('jumperMass');
cordMass = valuesMap('cordMass');
area = valuesMap('area');
weight = 9.81 * ( valuesMap('jumperMass') + valuesMap('cordMass') );
areaModulusProduct = area * valuesMap('modulus');
k = valuesMap('paramK');
n = valuesMap('paramN');
Ce = ( (weight/areaModulusProduct) + k*(weight/areaModulusProduct).^n + 1 );
CMCoeff = (jumperMass + 0.5*cordMass) / (jumperMass + cordMass);
elasticEnergy = bungee_elasticEnergy(Ce-1, valuesMap);
solution_2 = (maxVelocity*maxVelocity) / ...
(2*Ce*9.81*CMCoeff - 2*area*elasticEnergy/(jumperMass+cordMass));
solutions = [solutions solution_2];
end
nancheck = cellfun(@(x) any(isnan(valuesMap(x))), deplist{3}, 'un', 0);
if max(cell2mat(nancheck)) == 0
% disp('DEBUG: initialLengthSolve Solution3');
% Really terrible and slow work-around method
% ?D_cm F?_g/(L_0 ?_0^(e_D)¦s de) ˜ A_0
jumperMass = valuesMap('jumperMass');
cordMass = valuesMap('cordMass');
mass = jumperMass + cordMass;
cordArea = valuesMap('area');
maxLength = valuesMap('maxLength');
maxLengthCM = (maxLength * (jumperMass + 0.5*cordMass)) / mass;
gravEnergyArea = maxLengthCM*mass*9.81/cordArea;
% check if velocity increased
initialLength = maxLength/3.4;
while (initialLength*bungee_elasticEnergy((maxLength/initialLength)-1, valuesMap) < gravEnergyArea)
initialLength = initialLength - (initialLength / maxLength);
end
while (initialLength*bungee_elasticEnergy((maxLength/initialLength)-1, valuesMap) > gravEnergyArea)
initialLength = initialLength + (initialLength / maxLength);
end
solution_3 = initialLength;
solutions = [solutions solution_3];
end
end