bonjour,
voici une bizarrerie que je viens de rencontrer dans un programme en JAVA:
Cliquez pour afficherprivate void jButton4ActionPerformed(java.a wt.event.ActionEvent evt) {
if(u==1){
if(L3<=L1){
sf=F1;
bm=F1*(L3-L1);
} else{
sf=0;
bm=0;
}
f=-F1*Math.pow(L1,2)*(3*L-L1)/(6*E*igz);
strain=Math.sqrt(Math.abs((fn-t1)*f));
}else
if(u==2){
if(L3<=L1){
sf=(F1/s)*(L-L1-L2);
bm=(F1/s)*(L-L1-L2)*(L3-L1)-(F1/s)*Math.pow((L-L1-L2),2)/2;
}else if(L1<L3 & L3<=(L-L2)){
sf=-(F1/s)*(L3-L1)+(F1/s)*(L-L1-L2);
bm=-(F1/s)*Math.pow((L-L3-L2),2)/2;
}else{
sf=0;
bm=0;
}
f=-F1*Math.pow(L1,2)*(3*L-L1)/(6*E*igz)-F1*Math.pow((L-L2),2)*(2*L+L2)/(6*E*igz)-(F1/s)*Math.pow((L-L1-L2),4)/(8*E*igz);
strain=Math.sqrt(Math.abs((fn-t1)*f));
}else
if(u==3){
if(L3<=L1){
sf=-F1*(L-L1)/L;
bm=F1*(L-L1)*L3/L;
}else if(L3<=L){
sf=F1*(L1)/L;
bm=F1*(L-L3)*L1/L;
}
f=-F1*Math.pow(L1,2)*Math.pow((L-L1),2)/(3*E*igz*L);
strain=Math.sqrt(Math.abs((fn-t1)*f/2));
}else
if(u==4){
if(L3<=L1){
sf=-F1*(L-L1)/L;
bm=F1*(L-L1)*L3/L;
}else if(L1<L3 & L3<=(L-L2)){
sf=F2*(L-L2)/L-F1*(L-L1)/L;
bm=(F2*(L-L2)*L2/L-F1*(L-L1)*L1/L)*(L3-L1)/(L-L1-L2)+F1*(L-L1)*L1/L;
}else if(L3<=L){
sf=F2*(L-L2)/L;
bm=F2*(L-L3)*(L-L2)/L;
}
f=-F1*Math.pow(L1,2)*Math.pow((L-L1),2)/(3*E*igz*L)-F2*Math.pow(L2,2)*Math.pow((L-L2),2)/(3*E*igz*L);
strain=Math.sqrt(Math.abs((fn-t1)*f/2));
}else
if(u==5){
if(L3<=L1){
sf=-(F1/s)*(L-L1-L2)*(L-L1+L2)/(2*L);
bm=(F1/s)*(L-L1-L2)*(L-L1+L2)*L3/(2*L);
}else if(L1<L3 & L3<=(L-L2)){
sf=(F1/s)*(L3-L1)-(F1/s)*(L-L1-L2)*(L-L1+L2)/(2*L);
bm=(F1/s)*(L3-L1)*(L-L2-L3)/2+(F1/s)*(L-L1-L2)*(L-L1+L2)*L1/(2*L);
}else if(L3<=L){
sf=(F1/s)*(L-L1-L2)*(L+L1-L2)/(2*L);
bm=-(F1/s)*(L-L1-L2)*(L+L1-L2)*(L3-(L+L1-L2)/2)/(2*L)+(F1/s)*(L-L1-L2)*(L+L1-L2)*(L-L1+L2)/(4*L);
}
f=-5*(F1/s)*Math.pow((L-L1-L2),4)/(384*E*igz)-F1*Math.pow(L1,2)*Math.pow((L-L1),2)/(3*E*igz*L)-F1*Math.pow(L2,2)*Math.pow((L-L2),2)/(3*E*igz*L);
strain=Math.sqrt(Math.abs((fn-t1)*f/2));
}else
if(u==6){
if(L3<=(L-L1)){
sf=F1*(L1)/L;
bm=(-F1*L1/L)*L3;
}else if(L3<=L){
sf=-F1;
bm=F1*(L3-L)-F1*L1;
}
f=-F1*Math.pow(L1,2)*(L1+L)/(3*E*igz);
strain=Math.sqrt(Math.abs((fn-t1)*(Math.abs(f)+(F1*L1*Math.p ow(L,2)*Math.sqrt(3)/27*E*igz))));
}else
if(u==7){
if(L3<=L1){
sf=-F1*(L-L1)/L;
bm=F1*(L-L1)*L3/L-F1*(L-L1)*L1/(2*L);
}else if(L3<=L){
sf=F1*(L1)/L;
bm=F1*(L-L3)*L1/L+F1*(L-L1)*L1/(2*L);
}
f=-F1*Math.pow(L1,2)*Math.pow((L-L1),2)/(12*E*igz*L);
strain=Math.sqrt(Math.abs((fn-t1)*f/4));
}else
if(u==8){
if(L3<=L1){
sf=-F1*(L-L1)/L;
bm=F1*(L-L1)*L3/L-F1*(L-L1)*L1/(2*L);
}else if(L1<L3 & L3<=(L-L2)){
sf=F2*(L-L2)/L-F1*(L-L1)/L;
bm=(F2*(L2)*(L-L2)/(2*L)-F1*(L-L1)*L1/(2*L))*(L3-L1)/(L-L1-L2)+F1*(L-L1)*L1/(2*L);
}else if(L3<=L){
sf=F2*(L-L2)/L;
bm=F2*(L-L3)*(L-L2)/L+F2*(L2)*(L-L2)/(2*L);
}
f=-F1*Math.pow(L1,2)*Math.pow((L-L1),2)/(12*E*igz*L)-F2*Math.pow(L2,2)*Math.pow((L-L2),2)/(12*E*igz*L);
strain=Math.sqrt(Math.abs((fn-t1)*f/4));
}else
if(u==9){
if(L3<=L1){
sf=-(F1/s)*(L-L1-L2)*(L-L1+L2)/(2*L);
bm=(F1/s)*(L-L1-L2)*(L-L1+L2)*L3/(2*L)-(F1/s)*(L-L1-L2)*(L-L1+L2)*(L+L1-L2)/(4*L);
}else if(L1<L3 & L3<=(L-L2)){
sf=(F1/s)*(L3-L1)-(F1/s)*(L-L1-L2)*(L-L1+L2)/(2*L);
bm=(F1/s)*(L3-L1)*(L-L2-L3)/2+(F1/s)*(L-L1-L2)*(L-L1+L2)*L1/(2*L)+(F1/s)*(L-L1-L2)*(L-L1+L2)*(L+L1-L2)/(4*L);
}else if(L3<=L){
sf=(F1/s)*(L-L1-L2)*(L+L1-L2)/(2*L);
bm=-(F1/s)*(L-L1-L2)*(L+L1-L2)*(L3-(L+L1-L2)/2)/(2*L)+(F1/s)*(L-L1-L2)*(L+L1-L2)*(L-L1+L2)/(8*L);
}
f=-(F1/s)*Math.pow((L-L1-L2),4)/(384*E*igz)-F1*Math.pow(L1,2)*Math.pow((L-L1),2)/(12*E*igz*L)-F1*Math.pow(L2,2)*Math.pow((L-L2),2)/(12*E*igz*L);
strain=Math.sqrt(Math.abs((fn-t1)*f/4));
}
switch(jComboBox14.getSelected Index()) {
case 0:
jTextField34.setText(Double.to String(round(sf,3)));
break;
case 1:
jTextField34.setText(Double.to String(round(sf/1000,3)));
break;
}
switch(jComboBox15.getSelected Index()) {
case 0:
jTextField35.setText(Double.to String(round(bm,3)));
break;
case 1:
jTextField35.setText(Double.to String(round(bm/1000,3)));
break;
}
try {
Double.parseDouble(jTextField2 8.getText());
} catch(NumberFormatException e) {
JOptionPane.showMessageDialog( null,"Invalid Entries");
return;
}
switch(jComboBox20.getSelected Index()) {
case 0:
t1=Double.parseDouble(jTextFie ld28.getText());
break;
case 1:
t1=Double.parseDouble(jTextFie ld28.getText())*1000;
break;
}
stres=-bm*(fn-t1)/igz;
jTextField36.setText(Double.to String(round(stres,3)));
switch(jComboBox7.getSelectedI ndex()) {
case 0:
jTextField20.setText(Double.to String(round(strain,3)));
break;
case 1:
jTextField20.setText(Double.to String(round(strain/1000,3)));
break;
}
switch(jComboBox6.getSelectedI ndex()) {
case 0:
jTextField19.setText(Double.to String(round(f,3)));
break;
case 1:
jTextField19.setText(Double.to String(round(f/1000,3)));
break;
}
jTextField1.setText(Double.toS tring(t1));
jTextField18.setText(Double.to String(fn));
jTextField23.setText(Double.to String(fn-t1));
jTextField24.setText(Double.to String((fn-t1)*f));
jTextField25.setText(Double.to String(Math.abs((fn-t1)*f)));
jTextField26.setText(Double.to String(Math.sqrt(Math.abs((fn-t1)*f))));
jTextField27.setText(Double.to String(strain));
}
voici le probleme:
d'une facon generale lorque t1=fn, strain et stress sont nuls.
selon l'indice "u", la valeur de strain varie mais devrait tjrs etre nulle lorsque t1=fn
j'execute mon programme et j'essaie les valeurs t1=(0,6,12). pour stress c'est bon: nulle en 6, mini en 0 et maxi en 12.
pour strain c'est une autre histoire, je trouve une valeurs pout t1=6, je decide de verifier mes formules avec un crayon et un papier. ils ont l'air correctes.
j'ai donc ajouté des textfiels pour essayer l'equation de strain element par element.
c'est là que ça devient bizarre:
Double.toString(Math.sqrt(Math .abs((fn-t1)*f))) me donne bien "0" pour t1=6 alors que Double.toString(strain) me donne 4.67. et si vous regardez l'expression de strain pour u=1 c'est bien:
et pour tous les autres u c'est de la meme forme avec un coef 1/2 ou 1/4 en plus.strain=Math.sqrt(Math.abs((fn-t1)*f));
qqun pourrait-il m'expliquer d'ou vient ce truc, svp?
merci
-----