# *********** Calculate shear strain and shear force of a cylindric tube/rod from axial Strain. ch1: Strain in m/m **************
# Strain measured by strain gauge, whose strain gauge is sesitive in 45 angle to the axis
# Output x1 is the shear stress in N/mm and x5 is the force in N
# Usage: - make sure ch1 measures the strain in m/m, correctly parametrized. May change ch1 in formula below to other input channel.
# -Set the parameters constE, constV, constDa and constDi (don't erase the ; at the line end). For massive rod, set constDi= 0;
# Run the script.
# ******************************************************************************************
# Berechnet Querkraft und Schubspannung eines zylindrischen Rohres/Stabes aus der Dehnung eines DMS, dessen Messgitter im Winkel
# von 45 zur Lngsachse liegt
# x1 ist die Schubspannung in N/mm, x5 die Querkraft in N
# Verwendung: -Stellen Sie sicher, dass ch1 die Dehnung in m/m korrekt misst. GGf. zu anderem Eingangskanal ndern (ch2 usw).
# - Setzen Sie die Parameter constE, constV, constDa und constDi (nicht das ; lschen). Fuer massiven Stab: constDi= 0; setzen.

# https://www.me-systeme.de/de/support/kalkulator/querkraft2

# elastic modulus of the tube material / Elastizittsmodul des Rohrmaterials
constE= 73000;
# poissons ratio of the tube material / relatives Querkontraktions-Modul des Rohrmaterials
constV= 0.34;
#outer diameter in mm / Aussendurchmesser in mm
constDa= 200;
#inner diameter in mm. For a massive rod, set to 0  / Innendurchmesser in mm. Bei Vollrundstab: auf 0 setzen
constDi= 160;

# Output x1: shear stress / Ausgang x1: Querspannung
# $gmod = $emod / 2 / (1 + $pr);
# $gamma = 2*$strain;
#  $tau = $gmod * $gamma * 1.0E-6;
x1= ((constE/2)/(1+constV)) * ch1 * 2.0E-6;

constPI=3.1415926;
# x2: intermediate val, necessary for iteration
x2= constDi/1000;
# x3 Axiales-Flchenmoment Iy $iy_mm = $pi / 32 * ($da**4 - $di**4);
x3= (constPI/32) * ((constDa^4)-(constDi^4));
# x4 Axiales-Widerstandsmoment Wy $wy_mm = $iy_mm * $da / 2;
x4= (x3 * constDa)/2;
#x5: force in N / Axialkraft in N

IF(x2=0){x5=187500*constPI*((constDa/1000)^2)*x1};
ELIF(x2>0){x5=125000*constPI*((constDa/1000)+x2)*((constDa/1000)-x2)*x1};
ENDIF;
