Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86471075
hidden_code_nb_torsion.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Oct 6, 16:47
Size
48 KB
Mime Type
text/x-python
Expires
Tue, Oct 8, 16:47 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21428831
Attached To
R12408 DRIL_CIVIL-238
hidden_code_nb_torsion.py
View Options
import
math
import
numpy
as
np
from
bokeh.layouts
import
layout
,
column
,
row
from
bokeh.models.annotations
import
Label
,
Arrow
from
bokeh.models.arrow_heads
import
VeeHead
from
bokeh.models
import
Div
,
CustomJS
,
Slider
,
Spacer
,
Text
,
HoverTool
from
bokeh.models.widgets
import
RadioButtonGroup
,
CheckboxButtonGroup
from
bokeh.plotting
import
figure
,
show
,
ColumnDataSource
from
bokeh.io
import
output_notebook
from
cienpy
import
simplebeam
as
sb
from
cienpy
import
hollow_rectangular_section
as
beam_section
from
cienpy
import
stress_strain_elastic
as
stst
from
cienpy
import
models
from
cienpy
import
javascriptcodes
as
js
output_notebook
()
def
main_code
(
L
,
h
,
b
,
t
,
A
,
Iy
,
Iz
,
yG
,
y_n_axis
,
q
,
P
,
Mt
,
E
,
N
,
V
,
M
,
T
,
Rx
,
Ry_l
,
Ry_r
,
discr_NVM
,
x_discr
,
N_discr
,
V_discr
,
M_discr
,
T_discr
):
########################################################
# Initialisation
########################################################
# constants for the visualisation
SCALE
=
10
SCALE_T
=
10
OFFSET_Q
=
q
MAX_B
=
3
*
b
MAX_H
=
3
*
h
MAX_T
=
2
*
t
MAX_Q
=
q
/
4
*
5
# store the values in a specific format
data_beam
=
dict
(
x
=
[
0
,
L
],
y
=
[
0
,
0
]
)
data_scheme_beam
=
dict
(
x
=
[
0
,
L
*
SCALE
],
y
=
[
0
,
0
]
)
data_scheme_q
=
dict
(
x
=
[
0
,
0
,
L
*
SCALE
,
L
*
SCALE
],
y
=
[
OFFSET_Q
,
OFFSET_Q
+
q
,
OFFSET_Q
+
q
,
OFFSET_Q
],
x_fade
=
[
0
,
0
,
L
*
SCALE
,
L
*
SCALE
]
)
data_section_scheme
=
dict
(
x
=
[
0
,
0
],
y
=
[
0
,
h
]
)
initial_position
=
L
initial_state
=
'IDLE'
# possible cases: IDLE, R_SEC, L_SEC
initial_FBD
=
0
# right=0 left=1
data
=
dict
(
# stores every useful single variable
state
=
[
initial_state
],
FBD
=
[
initial_FBD
],
SCALE
=
[
SCALE
],
L
=
[
L
],
b
=
[
b
],
h
=
[
h
],
t
=
[
t
],
E
=
[
E
],
A
=
[
A
],
Iy
=
[
Iy
],
Iz
=
[
Iz
],
yG
=
[
yG
],
y_n_axis
=
[
y_n_axis
],
P
=
[
P
],
x
=
[
initial_position
],
y
=
[
0
],
q
=
[
q
],
Mt
=
[
Mt
],
Rx
=
[
Rx
],
Ry_l
=
[
Ry_l
],
Ry_r
=
[
Ry_r
],
N
=
[
N
],
V
=
[
V
],
M
=
[
M
],
T
=
[
T
],
xF
=
[
L
*
SCALE
]
)
source_beam
=
ColumnDataSource
(
data_beam
)
source_scheme_beam
=
ColumnDataSource
(
data_scheme_beam
)
source_scheme_q
=
ColumnDataSource
(
data_scheme_q
)
source_section_scheme
=
ColumnDataSource
(
data_section_scheme
)
source
=
ColumnDataSource
(
data
)
# Constants
FIG_H_B
=
200
# height figure beam
FIG_B_B
=
700
# width figure beam
FIG_H_S
=
FIG_H_B
# height figure scheme
FIG_B_S
=
FIG_B_B
# width figure scheme
FIG_H_SEC
=
600
# height figure section
DIV_B_GEO
=
170
DIV_B_FORCES
=
170
########################################################
# Define figures, widgets and renderers as from the previous notebook
########################################################
options
=
dict
(
toolbar_location
=
None
)
# figure for the beam
paddingx
=
0.2
*
L
int_x_b
=
(
0
-
paddingx
,
L
+
paddingx
)
int_y_b
=
(
-
OFFSET_Q
/
SCALE
,
(
MAX_Q
+
OFFSET_Q
)
/
SCALE
)
fig_beam
=
sb
.
define_fig_beam
(
int_x_b
,
int_y_b
,
options
,
f_h
=
FIG_H_B
,
f_b
=
FIG_B_B
)
# figure for the cross-section
fig_section
=
sb
.
define_fig_section
(
MAX_B
*
0.8
,
MAX_H
*
0.8
,
options
,
FIG_H_SEC
)
# beam
(
beam
,
support_l
,
support_r
)
=
sb
.
draw_beam
(
fig_beam
,
source_beam
,
L
,
ratio
=
(
int_y_b
[
1
]
-
int_y_b
[
0
])
/
FIG_H_B
*
100
)
# section
section
=
beam_section
.
draw_section
(
fig_section
,
b
,
h
,
t
)
# show mechanical parameters
div_geo
=
Div
(
width
=
DIV_B_GEO
,
text
=
beam_section
.
div_text_geo
(
round
(
h
),
round
(
b
),
round
(
t
),
round
(
L
),
"{:.2e}"
.
format
(
A
),
"{:.2e}"
.
format
(
Iy
),
"{:.2e}"
.
format
(
Iz
)))
# change geometry
slider_b
=
Slider
(
title
=
"Change the width b [mm]"
,
start
=
MAX_T
*
2
+
10
,
end
=
MAX_B
,
step
=
10
,
value
=
b
)
slider_h
=
Slider
(
title
=
"Change the height h [mm]"
,
start
=
MAX_T
*
2
+
10
,
end
=
MAX_H
,
step
=
10
,
value
=
h
)
# reference system
axis_arrow_length
=
0.8
axis_arrow_scale
=
100
models
.
force_vector
(
fig_section
,
axis_arrow_length
*
10
,
0
,
0
,
0
,
axis_arrow_length
*
axis_arrow_scale
*
1.6
,
'gray'
)
# y axis
fig_section
.
text
(
x
=
[
0
],
y
=
[
axis_arrow_length
*
axis_arrow_scale
*
1.7
],
text
=
[
"y"
],
text_color
=
'gray'
,
text_baseline
=
'middle'
,
angle
=
math
.
pi
/
2
)
models
.
force_vector
(
fig_section
,
axis_arrow_length
*
10
,
0
,
-
axis_arrow_length
*
axis_arrow_scale
,
0
,
0
,
'gray'
)
# z axis
fig_section
.
text
(
x
=
[
-
axis_arrow_length
*
axis_arrow_scale
*
1.1
],
y
=
[
0
],
text
=
[
"z"
],
text_color
=
'gray'
,
text_align
=
'right'
,
text_baseline
=
'middle'
)
# figure for the forces and moments
fig_scheme
=
sb
.
define_figure_scheme
(
L
,
SCALE
,
MAX_Q
,
OFFSET_Q
,
options
,
FIG_H_S
,
FIG_B_S
)
# uniform load (beam)
u_load
=
fig_beam
.
rect
([
L
/
2
],
[(
q
/
2
+
OFFSET_Q
)
/
SCALE
],
width
=
L
,
height
=
q
/
SCALE
,
fill_color
=
'blue'
,
color
=
'navy'
,
fill_alpha
=
0.6
,
alpha
=
0.6
)
label_u_load
=
fig_beam
.
text
(
x
=
[
-
0.2
],
y
=
[
OFFSET_Q
/
SCALE
],
text
=
[
"q"
],
text_color
=
"blue"
)
# axial force (beam)
axial_force
=
models
.
force_vector
(
fig_beam
,
P
,
L
+
P
/
SCALE
,
L
,
0
,
0
,
'green'
)
label_P_force
=
fig_beam
.
text
(
x
=
[
L
+
P
/
2
/
SCALE
],
y
=
[
OFFSET_Q
/
SCALE
/
4
],
text
=
[
"P"
],
text_color
=
"green"
)
# position point
pos_opt
=
dict
(
source
=
source
,
size
=
10
,
fill_alpha
=
0.5
,
fill_color
=
"magenta"
,
color
=
"magenta"
,
alpha
=
0.5
)
beam_position
=
fig_beam
.
circle
(
'x'
,
'y'
,
**
pos_opt
)
forces_position
=
fig_scheme
.
circle
(
'xF'
,
'y'
,
**
pos_opt
)
# beam (scheme)
scheme_beam
=
fig_scheme
.
line
(
'x'
,
'y'
,
source
=
source_scheme_beam
,
line_width
=
2
,
color
=
'black'
)
scheme_fade_beam
=
fig_scheme
.
line
(
x
=
[
0
,
L
*
SCALE
],
y
=
[
0
,
0
],
line_width
=
2
,
color
=
'black'
,
alpha
=
0.2
)
# uniform load (scheme)
scheme_u_load
=
fig_scheme
.
patch
(
'x'
,
'y'
,
source
=
source_scheme_q
,
fill_color
=
'blue'
,
color
=
'navy'
,
fill_alpha
=
0.3
,
alpha
=
0.3
)
scheme_fade_u_load
=
fig_scheme
.
patch
(
'x_fade'
,
'y'
,
source
=
source_scheme_q
,
fill_color
=
'blue'
,
color
=
'navy'
,
fill_alpha
=
0.3
,
alpha
=
0.3
)
# axial force (scheme)
scheme_axial_force
=
models
.
force_vector
(
fig_scheme
,
P
,
L
*
SCALE
+
P
,
L
*
SCALE
,
0
,
0
,
'green'
)
# Reactions (scheme)
scheme_Ry_r
=
models
.
force_vector
(
fig_scheme
,
Ry_r
,
L
*
SCALE
,
L
*
SCALE
,
-
Ry_r
,
0
,
'orange'
)
scheme_Ry_l
=
models
.
force_vector
(
fig_scheme
,
Ry_l
,
0
,
0
,
-
Ry_l
,
0
,
'orange'
)
scheme_Rx_l
=
models
.
force_vector
(
fig_scheme
,
Rx
,
-
Rx
,
0
,
0
,
0
,
'orange'
)
# force N
scheme_N
=
models
.
force_vector
(
fig_scheme
,
0
,
0
,
0
,
0
,
0
,
'red'
)
# force V
scheme_V
=
models
.
force_vector
(
fig_scheme
,
0
,
0
,
0
,
0
,
0
,
'red'
)
# moment M
(
scheme_M_line
,
scheme_M_head
,
source_M
)
=
models
.
define_curvedArrow
(
fig_scheme
,
0
,
0
,
0
,
size_head
=
0
)
# change the uniform load q
slider_q
=
Slider
(
title
=
"Change the uniform load q [kN/m]"
,
start
=
0.1
,
end
=
MAX_Q
,
step
=
0.1
,
value
=
q
)
# choose position of interest
slider_position
=
Slider
(
title
=
"Change the position x along the beam [m]"
,
start
=
0
,
end
=
L
,
step
=
0.02
,
value
=
L
)
# choose left or right FBD
div_rg_FBD
=
Div
(
text
=
"Free-body diagram (FBD):"
)
radiogroup_FBD
=
RadioButtonGroup
(
labels
=
[
'Right-hand'
,
'Left-hand'
],
active
=
initial_FBD
)
# choose axial force or not
div_cb_P
=
Div
(
text
=
f
"Axial force P={P} kN (applied)"
)
checkbox_P
=
CheckboxButtonGroup
(
labels
=
[
'Apply or remove axial force P'
],
active
=
[
0
])
# show values of forces and moments
div_forces
=
Div
(
width
=
DIV_B_FORCES
,
text
=
sb
.
div_text_forces
(
P
,
P
,
Ry_l
,
Ry_r
,
"No cross section analysed."
,
0
,
0
,
0
))
# figures for the diagrams
options_diag
=
dict
(
toolbar_location
=
None
,
x_axis_label
=
"Position [m]"
,
plot_width
=
FIG_B_B
,
x_range
=
fig_beam
.
x_range
)
fig_N
=
figure
(
**
options_diag
,
y_axis_label
=
"Axial force N [kN]"
,
plot_height
=
int
(
FIG_H_B
*
0.8
),
title
=
"N V M Diagrams"
)
fig_V
=
figure
(
**
options_diag
,
y_axis_label
=
"Shear force V [kN]"
,
plot_height
=
int
(
FIG_H_B
*
0.8
))
fig_M
=
figure
(
**
options_diag
,
y_axis_label
=
"Bending moment M [kNm]"
,
plot_height
=
FIG_H_B
)
fig_N
.
xaxis
.
visible
=
False
fig_V
.
xaxis
.
visible
=
False
# plot N V M
N_diag
=
models
.
NVM_diagram
(
fig_N
,
x_discr
,
N_discr
,
L
,
source_beam
)
fig_N
.
add_tools
(
HoverTool
(
renderers
=
[
N_diag
],
tooltips
=
[(
"Position"
,
"@x m"
),
(
"Axial force"
,
"@y kN"
)]))
V_diag
=
models
.
NVM_diagram
(
fig_V
,
x_discr
,
V_discr
,
L
,
source_beam
)
fig_V
.
add_tools
(
HoverTool
(
renderers
=
[
V_diag
],
tooltips
=
[(
"Position"
,
"@x m"
),
(
"Shear force"
,
"@y kN"
)]))
M_diag
=
models
.
NVM_diagram
(
fig_M
,
x_discr
,
M_discr
,
L
,
source_beam
)
fig_M
.
add_tools
(
HoverTool
(
renderers
=
[
M_diag
],
tooltips
=
[(
"Position"
,
"@x m"
),
(
"Bending moment"
,
"@y kNm"
)]))
# point that shows the position that it's analyzed
N_position
=
fig_N
.
circle
(
'x'
,
'N'
,
**
pos_opt
)
V_position
=
fig_V
.
circle
(
'x'
,
'V'
,
**
pos_opt
)
M_position
=
fig_M
.
circle
(
'x'
,
'M'
,
**
pos_opt
)
# figures for the stresses and strains
FIG_B_ss
=
200
FIG_H_ss
=
200
options_stress_strain
=
dict
(
toolbar_location
=
None
,
y_axis_label
=
"Height h [mm]"
,
plot_width
=
FIG_B_ss
,
plot_height
=
FIG_H_ss
,
)
fig_stress_N
=
figure
(
**
options_stress_strain
,
title
=
"Axial stress"
,
x_axis_label
=
"Stress
\N{GREEK SMALL LETTER SIGMA}\u2099
[MPa]"
)
fig_stress_N
.
yaxis
.
visible
=
False
fig_axial_strain
=
figure
(
**
options_stress_strain
,
title
=
"Axial strain"
,
x_axis_label
=
"Strain
\N{GREEK SMALL LETTER EPSILON}\u2099
[%]"
,
y_range
=
fig_stress_N
.
y_range
)
fig_axial_strain
.
yaxis
.
visible
=
False
fig_stress_M
=
figure
(
**
options_stress_strain
,
title
=
"Bending stress and centroid"
,
y_range
=
fig_stress_N
.
y_range
,
x_axis_label
=
"Stress
\N{GREEK SMALL LETTER SIGMA}\u2098
[MPa]"
)
fig_stress_M
.
yaxis
.
visible
=
False
fig_bending_strain
=
figure
(
**
options_stress_strain
,
title
=
"Bending strain"
,
x_axis_label
=
"Strain
\N{GREEK SMALL LETTER EPSILON}\u2098
[%]"
,
y_range
=
fig_stress_N
.
y_range
)
fig_bending_strain
.
yaxis
.
visible
=
False
fig_stress_V
=
figure
(
**
options_stress_strain
,
title
=
"Shear stress"
,
x_axis_label
=
"Stress
\N{GREEK SMALL LETTER TAU}\u1d65
[MPa]"
)
fig_stress_V
.
yaxis
.
visible
=
False
fig_stress_sigma
=
figure
(
**
options_stress_strain
,
title
=
"Total stress
\N{GREEK SMALL LETTER SIGMA}
and neutral axis"
,
y_range
=
fig_stress_N
.
y_range
,
y_axis_location
=
"right"
,
x_axis_label
=
"Stress
\N{GREEK SMALL LETTER SIGMA}
[MPa]"
)
fig_stress_tau
=
figure
(
**
options_stress_strain
,
title
=
"Total stress
\N{GREEK SMALL LETTER TAU}
"
,
y_range
=
fig_stress_V
.
y_range
,
y_axis_location
=
"right"
,
x_axis_label
=
"Stress
\N{GREEK SMALL LETTER TAU}
[MPa]"
)
# plot stress N V M
discr_stress_strain
=
201
scale_x
=
25
y_discr
=
np
.
linspace
(
0
,
h
,
discr_stress_strain
)
sigma_N
=
stst
.
compute_sigma_axial
(
y_discr
,
N
,
A
)
N_stress_diag
=
models
.
stress_diagram
(
fig_stress_N
,
sigma_N
,
h
,
source_section_scheme
,
scale_x
=
scale_x
/
10
)
fig_stress_N
.
add_tools
(
HoverTool
(
renderers
=
[
N_stress_diag
],
tooltips
=
[(
"Stress"
,
"@x MPa"
),
(
"Height"
,
"@y mm"
)]))
sigma_M
=
stst
.
compute_sigma_bending
(
y_discr
,
0
,
Iy
,
yG
)
(
M_stress_diag
,
centroid
)
=
models
.
stress_diagram
(
fig_stress_M
,
sigma_M
,
h
,
source_section_scheme
,
True
,
yG
,
scale_x
=
scale_x
)
fig_stress_M
.
add_tools
(
HoverTool
(
renderers
=
[
M_stress_diag
],
tooltips
=
[(
"Stress"
,
"@x MPa"
),
(
"Height"
,
"@y mm"
)]))
S_rect
=
beam_section
.
compute_first_moment_of_area
(
y_discr
,
b
,
h
,
t
,
yG
)
tau_V
=
stst
.
compute_tau_shear
(
y_discr
,
0
,
S_rect
,
Iy
,
b
)
V_stress_diag
=
models
.
stress_diagram
(
fig_stress_V
,
tau_V
,
h
,
source_section_scheme
,
scale_x
=
1
)
fig_stress_V
.
add_tools
(
HoverTool
(
renderers
=
[
V_stress_diag
],
tooltips
=
[(
"Stress"
,
"@x MPa"
),
(
"Height"
,
"@y mm"
)]))
# plot stress sigma and tau
sigma_total
=
sigma_M
+
sigma_N
(
sigma_stress_diag
,
neutral_axis
)
=
models
.
stress_diagram
(
fig_stress_sigma
,
sigma_total
,
h
,
source_section_scheme
,
True
,
yG
,
scale_x
=
scale_x
)
fig_stress_sigma
.
add_tools
(
HoverTool
(
renderers
=
[
sigma_stress_diag
],
tooltips
=
[(
"Stress"
,
"@x MPa"
),
(
"Height"
,
"@y mm"
)]))
tau_total
=
tau_V
tau_stress_diag
=
models
.
stress_diagram
(
fig_stress_tau
,
tau_total
,
h
,
source_section_scheme
,
scale_x
=
1
)
fig_stress_tau
.
add_tools
(
HoverTool
(
renderers
=
[
tau_stress_diag
],
tooltips
=
[(
"Stress"
,
"@x MPa"
),
(
"Height"
,
"@y mm"
)]))
# plot strain N M
strain_axial
=
stst
.
compute_epsilon_axial
(
y_discr
,
sigma_N
,
E
)
axial_strain_diag
=
models
.
strain_diagram
(
fig_axial_strain
,
strain_axial
,
h
,
source_section_scheme
)
fig_axial_strain
.
add_tools
(
HoverTool
(
renderers
=
[
axial_strain_diag
],
tooltips
=
[(
"Strain"
,
"@x %"
),
(
"Height"
,
"@y mm"
)]))
strain_bending
=
stst
.
compute_epsilon_bending
(
y_discr
,
sigma_M
,
E
)
bending_strain_diag
=
models
.
strain_diagram
(
fig_bending_strain
,
strain_bending
,
h
,
source_section_scheme
)
fig_bending_strain
.
add_tools
(
HoverTool
(
renderers
=
[
bending_strain_diag
],
tooltips
=
[(
"Strain"
,
"@x %"
),
(
"Height"
,
"@y mm"
)]))
# figures for NVM
fig_NM_section
=
figure
(
**
options_stress_strain
,
title
=
"N and M at position x"
,
match_aspect
=
True
)
fig_NM_section
.
axis
.
visible
=
False
fig_NM_section
.
grid
.
grid_line_alpha
=
0
fig_V_section
=
figure
(
**
options_stress_strain
,
title
=
"V at position x"
,
match_aspect
=
True
)
fig_V_section
.
axis
.
visible
=
False
fig_V_section
.
grid
.
grid_line_alpha
=
0
# section with NVM
models
.
section_diagram
(
fig_NM_section
)
models
.
section_diagram
(
fig_V_section
)
# NVM in section
section_N
=
models
.
force_vector
(
fig_NM_section
,
0
,
0
,
0
,
0
,
0
,
'red'
)
section_V
=
models
.
force_vector
(
fig_V_section
,
0
,
0
,
0
,
0
,
0
,
'red'
)
(
section_M_line
,
section_M_head
,
source_section_M
)
=
models
.
define_curvedArrow
(
fig_NM_section
,
0
,
0
,
0
,
size_head
=
0
)
# NVM label in section
OFFSET_N
=
1
label_N_section
=
fig_NM_section
.
text
(
x
=
[
P
*
1.1
],
y
=
[
OFFSET_N
],
text
=
[
""
],
text_color
=
"red"
,
text_baseline
=
'bottom'
)
label_M_section
=
fig_NM_section
.
text
(
x
=
[
OFFSET_N
*
6
],
y
=
[
-
OFFSET_N
*
5
],
text
=
[
""
],
text_color
=
"red"
,
text_baseline
=
'top'
)
label_V_section
=
fig_V_section
.
text
(
x
=
[
OFFSET_N
*
5
],
y
=
[
OFFSET_N
*
4
],
text
=
[
""
],
text_color
=
"red"
,
text_baseline
=
'middle'
)
########################################################
# Define the new figures, widgets and renderers
########################################################
# applied torsion Mt
str_Mt
=
"M
\N{LATIN SUBSCRIPT SMALL LETTER T}
"
div_cb_T
=
Div
(
text
=
f
"Torsion {str_Mt}={Mt} kNm (applied)"
)
checkbox_T
=
CheckboxButtonGroup
(
labels
=
[
f
'Apply or remove torsion {str_Mt}'
],
active
=
[
0
])
# torsion diagram
fig_M
.
plot_height
=
int
(
FIG_H_B
*
0.8
)
fig_M
.
xaxis
.
visible
=
False
fig_T
=
figure
(
**
options_diag
,
y_axis_label
=
"Torsion T [kNm]"
,
plot_height
=
FIG_H_B
)
# change geometry (thickness)
slider_t
=
Slider
(
title
=
"Change the thicknes t [mm]"
,
start
=
2
,
end
=
MAX_T
,
step
=
1
,
value
=
t
)
# plot T
T_diag
=
models
.
NVM_diagram
(
fig_T
,
x_discr
,
T_discr
,
L
,
source_beam
)
fig_T
.
add_tools
(
HoverTool
(
renderers
=
[
T_diag
],
tooltips
=
[(
"Position"
,
"@x m"
),
(
"Torsion"
,
"@y kNm"
)]))
# point that shows the position that it's analyzed
T_position
=
fig_T
.
circle
(
'x'
,
'T'
,
**
pos_opt
)
# figure for the stress tau_T
fig_stress_T
=
figure
(
**
options_stress_strain
,
title
=
"Torsional stress"
,
y_range
=
fig_stress_V
.
y_range
,
x_axis_label
=
"Stress
\N{GREEK SMALL LETTER TAU}\N{LATIN SUBSCRIPT SMALL LETTER T}
[MPa]"
)
fig_stress_T
.
yaxis
.
visible
=
False
# torsion in the section
(
section_torsion_line
,
section_torsion_head
,
section_torsion_source
)
=
models
.
define_curvedArrow
(
fig_section
,
0
,
T
*
4
/
SCALE_T
,
abs
(
T
*
3
/
SCALE_T
),
size_head
=
20
)
# moment Mt in beam
PIXEL2UNIT_BEAM
=
100
(
beam_torsion_line
,
beam_torsion_head
,
source_beam_torsion
)
=
models
.
define_doubleArrow
(
fig_beam
,
L
/
2
,
L
/
2
+
Mt
/
SCALE
/
10
,
0
,
0
,
arrow_color
=
"green"
,
pixel2unit
=
PIXEL2UNIT_BEAM
)
# label
label_Mt_force
=
fig_beam
.
text
(
x
=
[
L
/
2
+
Mt
/
2
/
SCALE
/
SCALE_T
],
y
=
[
OFFSET_Q
/
4
/
SCALE
/
SCALE_T
],
text
=
[
str_Mt
],
text_color
=
"green"
)
# add torsion in section stress
T_DOUBLE_HEAD_SIZE
=
10
(
section_T_line
,
section_T_head
,
section_T_source
)
=
models
.
define_doubleArrow
(
fig_V_section
,
OFFSET_N
*
4
-
T
/
SCALE_T
,
OFFSET_N
*
4
,
0
,
0
,
size_head
=
T_DOUBLE_HEAD_SIZE
)
# label
label_T_section
=
fig_V_section
.
text
(
x
=
[
Mt
*
1.1
/
SCALE_T
],
y
=
[
OFFSET_N
],
text
=
[
"T"
],
text_color
=
"red"
,
text_baseline
=
'bottom'
)
# tau stress torsion
tau_T
=
beam_section
.
compute_tau_torsion
(
y_discr
,
T
,
b
,
h
,
t
)
T_stress_diag
=
models
.
stress_diagram
(
fig_stress_T
,
tau_T
,
h
,
source_section_scheme
,
scale_x
=
1
)
fig_stress_T
.
add_tools
(
HoverTool
(
renderers
=
[
T_stress_diag
],
tooltips
=
[(
"Stress"
,
"@x MPa"
),
(
"Height"
,
"@y mm"
)]))
# Easter egg
EasterEgg1
=
fig_N
.
text
(
x
=
[
2
],
y
=
[
-
4
],
text
=
[
""
],
text_color
=
"purple"
,
text_font_size
=
"10px"
,
angle
=
math
.
pi
/
10
)
########################################################
# Configurethe logics
########################################################
args_slider_pos
=
dict
(
source
=
source
,
s_sb
=
source_scheme_beam
,
s_q
=
source_scheme_q
,
div_P
=
div_cb_P
,
div_f
=
div_forces
,
fP
=
scheme_axial_force
,
fRx
=
scheme_Rx_l
,
fRyl
=
scheme_Ry_l
,
fRyr
=
scheme_Ry_r
,
fN
=
scheme_N
,
fV
=
scheme_V
,
s_M
=
source_M
,
arr_head
=
scheme_M_head
,
centroid
=
centroid
,
neutral_axis
=
neutral_axis
,
N_stress_diag
=
N_stress_diag
,
axial_strain_diag
=
axial_strain_diag
,
V_stress_diag
=
V_stress_diag
,
M_stress_diag
=
M_stress_diag
,
bending_strain_diag
=
bending_strain_diag
,
sigma_stress_diag
=
sigma_stress_diag
,
tau_stress_diag
=
tau_stress_diag
,
section_N
=
section_N
,
section_V
=
section_V
,
section_M_head
=
section_M_head
,
s_section_M
=
source_section_M
,
label_N_section
=
label_N_section
,
label_V_section
=
label_V_section
,
label_M_section
=
label_M_section
,
section_T_line
=
section_T_line
,
section_T_head
=
section_T_head
,
section_T_source
=
section_T_source
,
section_torsion_head
=
section_torsion_head
,
section_torsion_source
=
section_torsion_source
,
label_T_section
=
label_T_section
,
div_T
=
div_cb_T
,
T_stress_diag
=
T_stress_diag
)
code_slider_pos
=
f
"""
// retrieve data
const db = source.data
const data_sb = s_sb.data
const data_q = s_q.data
const FBD = db['FBD'][0]
const pos = cb_obj.value
const q = db['q'][0]
const L = db['L'][0]
const Mt = db['Mt'][0]
// update data
db['N'][0] = compute_N(db['P'][0])
db['V'][0] = compute_V(pos, q, L)
db['M'][0] = compute_M(pos, q, L)
db['T'][0] = compute_T(pos, Mt, L)
db['x'][0] = pos
// check state
check_state(db)
// update:
update_internal_forces(db, fN, fV, arr_head, s_M)
update_scheme_position(db, data_sb, data_q)
update_reactions(db, fRx, fRyl, fRyr)
update_external_forces(db, fP, div_P)
update_div_forces(db, div_f)
update_axial_stress_strain(db, N_stress_diag, axial_strain_diag)
update_bending_stress_strain(db, M_stress_diag, bending_strain_diag, centroid)
update_shear_stress(db, V_stress_diag)
update_total_stress(db, sigma_stress_diag, tau_stress_diag, neutral_axis)
update_NVM_section(db, section_N, section_V, section_M_head, s_section_M, label_N_section, label_V_section, label_M_section)
update_T_section(db, section_torsion_head, section_torsion_source, section_T_line, section_T_head, section_T_source, div_T, label_T_section)
update_torsional_stress(db, T_stress_diag)
// apply the changes
source.change.emit()
s_sb.change.emit()
s_q.change.emit()
// declare functions
{sb.implement_compute_NJS()}
{sb.implement_compute_VJS()}
{sb.implement_compute_MJS()}
{sb.implement_update_internal_forcesJS()}
{sb.implement_update_scheme_positionJS()}
{sb.implement_update_reactionsJS()}
{sb.implement_update_external_forcesJS()}
{sb.implement_update_div_forcesJS()}
{js.implement_linspaceJS()}
{js.implement_parabolaJS()}
{js.implement_arrow_alphaJS()}
{js.implement_update_arrowJS()}
{js.implement_arrow_growthJS()}
{js.implement_update_curvedArrowJS()}
{js.implement_update_NVM_diagramJS()}
{js.implement_update_stress_diagramJS()}
{models.implement_check_stateJS()}
{js.implement_update_strain_diagramJS()}
{beam_section.implement_compute_first_moment_of_areaJS()}
{beam_section.implement_compute_first_moment_of_area_implicitJS()}
{stst.implement_compute_sigma_axialJS()}
{stst.implement_compute_sigma_bendingJS()}
{stst.implement_compute_tau_shearJS()}
{stst.implement_compute_epsilon_axialJS()}
{stst.implement_compute_epsilon_bendingJS()}
{stst.implement_compute_total_sigmaJS()}
{stst.implement_compute_total_tauJS()}
{stst.implement_compute_neutral_axisJS()}
{js.implement_update_axial_stress_strainJS(discr_stress_strain)}
{js.implement_update_bending_stress_strainJS(discr_stress_strain)}
{js.implement_update_shear_stressJS(discr_stress_strain, hollow_rectangular_section=True)}
{js.implement_update_total_stressJS(discr_stress_strain, T_opt=True, hollow_rectangular_section=True)}
{js.implement_update_NVM_sectionJS()}
{sb.implement_update_T_sectionJS(scale_T=SCALE_T)}
{js.implement_update_doubleArrowJS()}
{sb.implement_compute_TJS()}
{beam_section.implement_compute_tau_torsionJS()}
{beam_section.implement_update_torsional_stressJS(discr_stress_strain)}
"""
updade_slider_pos
=
CustomJS
(
args
=
args_slider_pos
,
code
=
code_slider_pos
)
args_slider_b
=
dict
(
source
=
source
,
s_b
=
source_beam
,
div
=
div_geo
,
section
=
section
,
support_r
=
support_r
,
centroid
=
centroid
,
neutral_axis
=
neutral_axis
,
N_stress_diag
=
N_stress_diag
,
axial_strain_diag
=
axial_strain_diag
,
V_stress_diag
=
V_stress_diag
,
M_stress_diag
=
M_stress_diag
,
bending_strain_diag
=
bending_strain_diag
,
sigma_stress_diag
=
sigma_stress_diag
,
tau_stress_diag
=
tau_stress_diag
,
T_stress_diag
=
T_stress_diag
,
div_P
=
div_cb_P
)
code_change_b
=
f
"""
// retrieve data used
const db = source.data
const b = cb_obj.value // value of the slider
const h = db['h'][0]
const t = db['t'][0]
const A = compute_area(b, h, t)
const Iy = compute_inertia_y(b, h, t)
const yG = db['yG'][0]
const N = db['N'][0]
const M = db['M'][0]
// Easter egg
const str_Doge = " such width"
const str_tmp = div_P.text
if (b == {MAX_B}) {{
div_P.text = str_tmp+str_Doge
}} else {{
div_P.text = str_tmp.replace(str_Doge, '')
}}
// apply the changes
db['b'][0] = b
db['A'][0] = A
db['Iy'][0] = Iy
db['Iz'][0] = compute_inertia_z(b, h, t)
db['y_n_axis'][0] = compute_neutral_axis(N, A, Iy, M, yG)
// update
update_div_geo(db, div)
update_section(db, section)
update_axial_stress_strain(db, N_stress_diag, axial_strain_diag)
update_bending_stress_strain(db, M_stress_diag, bending_strain_diag, centroid)
update_shear_stress(db, V_stress_diag)
update_total_stress(db, sigma_stress_diag, tau_stress_diag, neutral_axis)
update_torsional_stress(db, T_stress_diag)
// emit the changes
source.change.emit()
{beam_section.implement_update_div_geoJS()}
{beam_section.implement_update_sectionJS()}
{beam_section.implement_compute_areaJS()}
{beam_section.implement_compute_inertia_yJS()}
{beam_section.implement_compute_inertia_zJS()}
{stst.implement_compute_neutral_axisJS()}
{js.implement_update_axial_stress_strainJS(discr_stress_strain)}
{js.implement_update_bending_stress_strainJS(discr_stress_strain)}
{js.implement_update_shear_stressJS(discr_stress_strain, hollow_rectangular_section=True)}
{js.implement_update_total_stressJS(discr_stress_strain, T_opt=True, hollow_rectangular_section=True)}
{js.implement_linspaceJS()}
{stst.implement_compute_epsilon_axialJS()}
{stst.implement_compute_epsilon_bendingJS()}
{stst.implement_compute_sigma_axialJS()}
{js.implement_update_stress_diagramJS()}
{js.implement_update_strain_diagramJS()}
{stst.implement_compute_sigma_bendingJS()}
{stst.implement_compute_total_sigmaJS()}
{stst.implement_compute_total_tauJS()}
{beam_section.implement_compute_first_moment_of_areaJS()}
{beam_section.implement_compute_first_moment_of_area_implicitJS()}
{stst.implement_compute_tau_shearJS()}
{beam_section.implement_compute_centroid_yJS()}
{stst.implement_compute_neutral_axisJS()}
{beam_section.implement_compute_tau_torsionJS()}
{beam_section.implement_update_torsional_stressJS(discr_stress_strain)}
"""
update_b
=
CustomJS
(
args
=
args_slider_b
,
code
=
code_change_b
)
args_slider_h
=
dict
(
source
=
source
,
s_b
=
source_beam
,
s_ss
=
source_section_scheme
,
div
=
div_geo
,
section
=
section
,
support_r
=
support_r
,
centroid
=
centroid
,
neutral_axis
=
neutral_axis
,
N_stress_diag
=
N_stress_diag
,
axial_strain_diag
=
axial_strain_diag
,
V_stress_diag
=
V_stress_diag
,
M_stress_diag
=
M_stress_diag
,
bending_strain_diag
=
bending_strain_diag
,
sigma_stress_diag
=
sigma_stress_diag
,
tau_stress_diag
=
tau_stress_diag
,
T_stress_diag
=
T_stress_diag
,
div_T
=
div_cb_T
,
EE1
=
EasterEgg1
)
code_change_h
=
f
"""
// retrieve data used
const db = source.data
const data_ss = s_ss.data
const b = db['b'][0]
const t = db['t'][0]
const h = cb_obj.value // value of the slider
const A = compute_area(b, h, t)
const Iy = compute_inertia_y(b, h, t)
const N = db['N'][0]
const M = db['M'][0]
const yG = compute_centroid_y(h)
// Easter egg
/*const str_Doge = " much wow"
const str_tmp = div_T.text
if (h == {MAX_H}) {{
div_T.text = str_tmp+str_Doge
}} else {{
div_T.text = str_tmp.replace(str_Doge, '')
}}*/
if (h == {MAX_H}) {{
EE1.glyph.text = "much wow"
}} else {{
EE1.glyph.text = ""
}}
// apply the changes
db['h'][0] = h
db['A'][0] = A
db['Iy'][0] = Iy
db['Iz'][0] = compute_inertia_z(b, h, t)
db['yG'][0] = yG
db['y_n_axis'][0] = compute_neutral_axis(N, A, Iy, M, yG)
data_ss['y'][1] = h // change the height of the section in the diagrams
// update
update_div_geo(db, div)
update_section(db, section)
update_axial_stress_strain(db, N_stress_diag, axial_strain_diag)
update_bending_stress_strain(db, M_stress_diag, bending_strain_diag, centroid)
update_shear_stress(db, V_stress_diag)
update_total_stress(db, sigma_stress_diag, tau_stress_diag, neutral_axis)
update_torsional_stress(db, T_stress_diag)
// emit the changes
source.change.emit()
s_ss.change.emit()
{beam_section.implement_update_div_geoJS()}
{beam_section.implement_update_sectionJS()}
{beam_section.implement_compute_areaJS()}
{beam_section.implement_compute_inertia_yJS()}
{beam_section.implement_compute_inertia_zJS()}
{beam_section.implement_compute_centroid_yJS()}
{stst.implement_compute_neutral_axisJS()}
{js.implement_update_axial_stress_strainJS(discr_stress_strain)}
{js.implement_update_bending_stress_strainJS(discr_stress_strain)}
{js.implement_update_shear_stressJS(discr_stress_strain, hollow_rectangular_section=True)}
{js.implement_update_total_stressJS(discr_stress_strain, T_opt=True, hollow_rectangular_section=True)}
{js.implement_linspaceJS()}
{stst.implement_compute_epsilon_axialJS()}
{stst.implement_compute_epsilon_bendingJS()}
{stst.implement_compute_sigma_axialJS()}
{js.implement_update_stress_diagramJS()}
{js.implement_update_strain_diagramJS()}
{stst.implement_compute_sigma_bendingJS()}
{stst.implement_compute_total_sigmaJS()}
{stst.implement_compute_total_tauJS()}
{beam_section.implement_compute_first_moment_of_areaJS()}
{beam_section.implement_compute_first_moment_of_area_implicitJS()}
{stst.implement_compute_tau_shearJS()}
{beam_section.implement_compute_tau_torsionJS()}
{beam_section.implement_update_torsional_stressJS(discr_stress_strain)}
"""
update_h
=
CustomJS
(
args
=
args_slider_h
,
code
=
code_change_h
)
args_checkbox_P
=
dict
(
source
=
source
,
s_M
=
source_M
,
div_P
=
div_cb_P
,
div_f
=
div_forces
,
fP
=
scheme_axial_force
,
fRx
=
scheme_Rx_l
,
fRyl
=
scheme_Ry_l
,
fRyr
=
scheme_Ry_r
,
fN
=
scheme_N
,
fV
=
scheme_V
,
arr_head
=
scheme_M_head
,
N_diag
=
N_diag
,
neutral_axis
=
neutral_axis
,
N_stress_diag
=
N_stress_diag
,
axial_strain_diag
=
axial_strain_diag
,
sigma_stress_diag
=
sigma_stress_diag
,
tau_stress_diag
=
tau_stress_diag
,
section_N
=
section_N
,
section_V
=
section_V
,
section_M_head
=
section_M_head
,
s_section_M
=
source_section_M
,
label_N_section
=
label_N_section
,
label_V_section
=
label_V_section
,
label_M_section
=
label_M_section
)
code_checkbox_P
=
f
"""
// retrieve var from the object that uses callback
var f = cb_obj.active // checkbox P
if (f.length==0) f = [1]
const db = source.data
// apply the changes
db['P'][0] = {P}*(1-f)
db['N'][0] = compute_N(db['P'][0])
db['Rx'][0] = compute_Rx(db['P'][0])
// update
update_reactions(db, fRx, fRyl, fRyr)
update_external_forces(db, fP, div_P)
update_N_diagram(db, N_diag)
update_internal_forces(db, fN, fV, arr_head, s_M)
update_div_forces(db, div_f)
update_axial_stress_strain(db, N_stress_diag, axial_strain_diag)
update_total_stress(db, sigma_stress_diag, tau_stress_diag, neutral_axis)
update_NVM_section(db, section_N, section_V, section_M_head, s_section_M, label_N_section, label_V_section, label_M_section)
// emit the changes
source.change.emit()
// declare functions
{sb.implement_update_external_forcesJS()}
{sb.implement_update_reactionsJS()}
{sb.implement_compute_RxJS()}
{js.implement_update_arrowJS()}
{js.implement_arrow_alphaJS()}
{js.implement_update_NVM_diagramJS()}
{sb.implement_compute_NJS()}
{sb.implement_update_N_diagramJS(discr_NVM)}
{sb.implement_update_internal_forcesJS()}
{js.implement_update_curvedArrowJS()}
{js.implement_update_axial_stress_strainJS(discr_stress_strain)}
{js.implement_update_total_stressJS(discr_stress_strain, T_opt=True, hollow_rectangular_section=True)}
{js.implement_linspaceJS()}
{stst.implement_compute_epsilon_axialJS()}
{stst.implement_compute_sigma_axialJS()}
{js.implement_update_stress_diagramJS()}
{js.implement_update_strain_diagramJS()}
{stst.implement_compute_neutral_axisJS()}
{stst.implement_compute_sigma_bendingJS()}
{stst.implement_compute_total_sigmaJS()}
{stst.implement_compute_total_tauJS()}
{beam_section.implement_compute_first_moment_of_areaJS()}
{beam_section.implement_compute_first_moment_of_area_implicitJS()}
{stst.implement_compute_tau_shearJS()}
{sb.implement_update_div_forcesJS()}
{js.implement_update_NVM_sectionJS()}
{js.implement_arrow_growthJS()}
{beam_section.implement_compute_tau_torsionJS()}
"""
update_checkbox_P
=
CustomJS
(
args
=
args_checkbox_P
,
code
=
code_checkbox_P
)
args_radiogroup_FBD
=
dict
(
source
=
source
,
s_sb
=
source_scheme_beam
,
s_q
=
source_scheme_q
,
s_M
=
source_M
,
div_P
=
div_cb_P
,
fP
=
scheme_axial_force
,
fRx
=
scheme_Rx_l
,
fRyl
=
scheme_Ry_l
,
fRyr
=
scheme_Ry_r
,
fN
=
scheme_N
,
fV
=
scheme_V
,
arr_head
=
scheme_M_head
,
tau_stress_diag
=
tau_stress_diag
)
code_radiogroup_FBD
=
f
"""
// retrieve data
const db = source.data
const FBD = cb_obj.active
const data_sb = s_sb.data
const data_q = s_q.data
const pos = db['x'][0]
// apply the changes
db['FBD'][0] = FBD
// update
check_state(db)
update_internal_forces(db, fN, fV, arr_head, s_M)
update_scheme_position(db, data_sb, data_q)
update_reactions(db, fRx, fRyl, fRyr)
update_external_forces(db, fP, div_P)
// emit the changes
source.change.emit()
s_sb.change.emit()
s_q.change.emit()
{models.implement_check_stateJS()}
{sb.implement_update_internal_forcesJS()}
{sb.implement_update_scheme_positionJS()}
{js.implement_update_curvedArrowJS()}
{js.implement_update_arrowJS()}
{sb.implement_update_reactionsJS()}
{sb.implement_update_external_forcesJS()}
{js.implement_arrow_alphaJS()}
{js.implement_update_NVM_sectionJS()}
{js.implement_arrow_growthJS()}
"""
update_radiogroup_FBD
=
CustomJS
(
args
=
args_radiogroup_FBD
,
code
=
code_radiogroup_FBD
)
args_slider_q
=
dict
(
source
=
source
,
s_q
=
source_scheme_q
,
s_M
=
source_M
,
div_f
=
div_forces
,
div_P
=
div_cb_P
,
fP
=
scheme_axial_force
,
fRx
=
scheme_Rx_l
,
fRyl
=
scheme_Ry_l
,
fRyr
=
scheme_Ry_r
,
fN
=
scheme_N
,
fV
=
scheme_V
,
arr_head
=
scheme_M_head
,
V_diag
=
V_diag
,
M_diag
=
M_diag
,
centroid
=
centroid
,
neutral_axis
=
neutral_axis
,
V_stress_diag
=
V_stress_diag
,
M_stress_diag
=
M_stress_diag
,
bending_strain_diag
=
bending_strain_diag
,
sigma_stress_diag
=
sigma_stress_diag
,
tau_stress_diag
=
tau_stress_diag
,
section_N
=
section_N
,
section_V
=
section_V
,
section_M_head
=
section_M_head
,
s_section_M
=
source_section_M
,
label_N_section
=
label_N_section
,
label_V_section
=
label_V_section
,
label_M_section
=
label_M_section
)
code_slider_q
=
f
"""
// retrieve data
const db = source.data
const q = cb_obj.value
const pos = db['x'][0]
const L = db['L'][0]
// update q
db['q'][0] = q
db['V'][0] = compute_V(pos, q, L)
db['M'][0] = compute_M(pos, q, L)
db['Ry_l'][0] = compute_Ry_l(q, L)
db['Ry_r'][0] = compute_Ry_r(q, L)
// update
update_u_load(db, s_q)
update_reactions(db, fRx, fRyl, fRyr)
update_external_forces(db, fP, div_P)
update_V_diagram(db, V_diag)
update_M_diagram(db, M_diag)
update_internal_forces(db, fN, fV, arr_head, s_M)
update_div_forces(db, div_f)
update_bending_stress_strain(db, M_stress_diag, bending_strain_diag, centroid)
update_shear_stress(db, V_stress_diag)
update_total_stress(db, sigma_stress_diag, tau_stress_diag, neutral_axis)
update_NVM_section(db, section_N, section_V, section_M_head, s_section_M, label_N_section, label_V_section, label_M_section)
// apply changes
source.change.emit()
// declare functions
{js.implement_update_arrowJS()}
{js.implement_linspaceJS()}
{js.implement_parabolaJS()}
{js.implement_arrow_alphaJS()}
{js.implement_update_arrowJS()}
{sb.implement_compute_VJS()}
{sb.implement_compute_MJS()}
{sb.implement_compute_Ry_lJS()}
{sb.implement_compute_Ry_rJS()}
{js.implement_update_NVM_diagramJS()}
{sb.implement_update_V_diagramJS(discr_NVM)}
{sb.implement_update_M_diagramJS(discr_NVM)}
{sb.implement_update_reactionsJS()}
{sb.implement_update_external_forcesJS()}
{sb.implement_update_u_loadJS(OFFSET_Q)}
{sb.implement_update_internal_forcesJS()}
{js.implement_update_curvedArrowJS()}
{js.implement_update_axial_stress_strainJS(discr_stress_strain)}
{js.implement_update_bending_stress_strainJS(discr_stress_strain)}
{js.implement_update_shear_stressJS(discr_stress_strain, hollow_rectangular_section=True)}
{js.implement_update_total_stressJS(discr_stress_strain, T_opt=True, hollow_rectangular_section=True)}
{stst.implement_compute_epsilon_bendingJS()}
{stst.implement_compute_sigma_axialJS()}
{js.implement_update_stress_diagramJS()}
{js.implement_update_strain_diagramJS()}
{stst.implement_compute_neutral_axisJS()}
{beam_section.implement_compute_centroid_yJS()}
{stst.implement_compute_sigma_bendingJS()}
{stst.implement_compute_total_sigmaJS()}
{stst.implement_compute_total_tauJS()}
{beam_section.implement_compute_first_moment_of_areaJS()}
{beam_section.implement_compute_first_moment_of_area_implicitJS()}
{stst.implement_compute_tau_shearJS()}
{sb.implement_update_div_forcesJS()}
{js.implement_update_NVM_sectionJS()}
{js.implement_arrow_growthJS()}
{beam_section.implement_compute_tau_torsionJS()}
"""
update_slider_q
=
CustomJS
(
args
=
args_slider_q
,
code
=
code_slider_q
)
args_checkbox_T
=
dict
(
source
=
source
,
T_diag
=
T_diag
,
div_T
=
div_cb_T
,
label_T_section
=
label_T_section
,
section_T_line
=
section_T_line
,
section_T_head
=
section_T_head
,
section_T_source
=
section_T_source
,
section_torsion_head
=
section_torsion_head
,
section_torsion_source
=
section_torsion_source
,
neutral_axis
=
neutral_axis
,
sigma_stress_diag
=
sigma_stress_diag
,
tau_stress_diag
=
tau_stress_diag
,
T_stress_diag
=
T_stress_diag
)
code_checkbox_T
=
f
"""
// retrieve var from the object that uses callback
var f = cb_obj.active // checkbox Mt
if (f.length==0) f = [1]
const db = source.data
const L = db['L'][0]
const x = db['x'][0]
// apply the changes
db['Mt'][0] = {Mt}*(1-f)
db['T'][0] = compute_T(x, db['Mt'][0], L)
// update
update_torsional_stress(db, T_stress_diag)
update_total_stress(db, sigma_stress_diag, tau_stress_diag, neutral_axis)
update_T_diagram(db, T_diag)
update_T_section(db, section_torsion_head, section_torsion_source, section_T_line, section_T_head, section_T_source, div_T, label_T_section)
// emit the changes
source.change.emit()
// declare functions
{js.implement_update_curvedArrowJS()}
{js.implement_update_doubleArrowJS()}
{js.implement_arrow_growthJS()}
{sb.implement_update_T_sectionJS(scale_T=SCALE_T)}
{sb.implement_compute_TJS()}
{sb.implement_update_T_diagramJS(discr_NVM)}
{js.implement_linspaceJS()}
{js.implement_update_NVM_diagramJS()}
{beam_section.implement_compute_tau_torsionJS()}
{js.implement_update_total_stressJS(discr_stress_strain, T_opt=True, hollow_rectangular_section=True)}
{stst.implement_compute_neutral_axisJS()}
{stst.implement_compute_sigma_axialJS()}
{stst.implement_compute_sigma_bendingJS()}
{stst.implement_compute_total_sigmaJS()}
{stst.implement_compute_total_tauJS()}
{beam_section.implement_compute_first_moment_of_areaJS()}
{beam_section.implement_compute_first_moment_of_area_implicitJS()}
{stst.implement_compute_tau_shearJS()}
{js.implement_update_stress_diagramJS()}
{beam_section.implement_update_torsional_stressJS(discr_stress_strain)}
"""
update_checkbox_T
=
CustomJS
(
args
=
args_checkbox_T
,
code
=
code_checkbox_T
)
args_slider_t
=
dict
(
source
=
source
,
div
=
div_geo
,
section
=
section
,
N_stress_diag
=
N_stress_diag
,
axial_strain_diag
=
axial_strain_diag
,
M_stress_diag
=
M_stress_diag
,
bending_strain_diag
=
bending_strain_diag
,
centroid
=
centroid
,
V_stress_diag
=
V_stress_diag
,
sigma_stress_diag
=
sigma_stress_diag
,
tau_stress_diag
=
tau_stress_diag
,
neutral_axis
=
neutral_axis
,
T_stress_diag
=
T_stress_diag
)
code_change_t
=
f
"""
// retrieve data used
const db = source.data
const t = cb_obj.value // value of the slider
const b = db['b'][0]
const h = db['h'][0]
const A = compute_area(b, h, t)
const Iy = compute_inertia_y(b, h, t)
const yG = db['yG'][0]
const N = db['N'][0]
const M = db['M'][0]
// apply the changes
db['t'][0] = t
db['A'][0] = A
db['Iy'][0] = Iy
db['Iz'][0] = compute_inertia_z(b, h, t)
db['y_n_axis'][0] = compute_neutral_axis(N, A, Iy, M, yG)
// update
update_div_geo(db, div)
update_section(db, section)
update_axial_stress_strain(db, N_stress_diag, axial_strain_diag)
update_bending_stress_strain(db, M_stress_diag, bending_strain_diag, centroid)
update_shear_stress(db, V_stress_diag)
update_torsional_stress(db, T_stress_diag)
update_total_stress(db, sigma_stress_diag, tau_stress_diag, neutral_axis)
// emit the changes
source.change.emit()
{beam_section.implement_update_div_geoJS()}
{beam_section.implement_update_sectionJS()}
{beam_section.implement_compute_areaJS()}
{beam_section.implement_compute_inertia_yJS()}
{beam_section.implement_compute_inertia_zJS()}
{stst.implement_compute_neutral_axisJS()}
{js.implement_update_axial_stress_strainJS(discr_stress_strain)}
{js.implement_update_bending_stress_strainJS(discr_stress_strain)}
{js.implement_update_shear_stressJS(discr_stress_strain, hollow_rectangular_section=True)}
{js.implement_update_total_stressJS(discr_stress_strain, T_opt=True, hollow_rectangular_section=True)}
{js.implement_linspaceJS()}
{stst.implement_compute_epsilon_axialJS()}
{stst.implement_compute_epsilon_bendingJS()}
{stst.implement_compute_sigma_axialJS()}
{js.implement_update_stress_diagramJS()}
{js.implement_update_strain_diagramJS()}
{stst.implement_compute_sigma_bendingJS()}
{stst.implement_compute_total_sigmaJS()}
{stst.implement_compute_total_tauJS()}
{beam_section.implement_compute_first_moment_of_areaJS()}
{beam_section.implement_compute_first_moment_of_area_implicitJS()}
{stst.implement_compute_tau_shearJS()}
{beam_section.implement_compute_tau_torsionJS()}
{beam_section.implement_update_torsional_stressJS(discr_stress_strain)}
"""
update_t
=
CustomJS
(
args
=
args_slider_t
,
code
=
code_change_t
)
# apply the logics
slider_b
.
js_on_change
(
'value'
,
update_b
)
slider_h
.
js_on_change
(
'value'
,
update_h
)
slider_position
.
js_on_change
(
'value'
,
updade_slider_pos
)
checkbox_P
.
js_on_click
(
update_checkbox_P
)
radiogroup_FBD
.
js_on_click
(
update_radiogroup_FBD
)
slider_q
.
js_on_change
(
'value'
,
update_slider_q
)
slider_t
.
js_on_change
(
'value'
,
update_t
)
checkbox_T
.
js_on_click
(
update_checkbox_T
)
########################################################
# Build the layout
########################################################
padding_layout
=
10
layout1
=
layout
([
[
column
(
row
(
column
(
fig_scheme
,
row
(
fig_section
,
Spacer
(
width
=
padding_layout
),
column
(
Spacer
(
height
=
padding_layout
*
3
),
slider_b
,
slider_h
,
slider_t
,
# row(div_geo, div_forces),
slider_position
,
slider_q
,
Spacer
(
height
=
padding_layout
*
3
),
div_rg_FBD
,
radiogroup_FBD
,
div_cb_P
,
checkbox_P
,
Spacer
(
height
=
padding_layout
*
3
),
div_cb_T
,
checkbox_T
))),
column
(
fig_beam
,
Spacer
(
height
=
padding_layout
),
fig_N
,
fig_V
,
fig_M
,
fig_T
)),
row
(
column
(
row
(
fig_NM_section
,
fig_axial_strain
,
fig_stress_N
,
fig_bending_strain
,
fig_stress_M
,
fig_stress_sigma
),
row
(
fig_V_section
,
Spacer
(
width
=
FIG_B_ss
),
fig_stress_V
,
Spacer
(
width
=
FIG_B_ss
),
fig_stress_T
,
fig_stress_tau
),
))
),
],
])
show
(
layout1
)
Event Timeline
Log In to Comment