I have the following program which i need to repeat steps until until two variables converge and I want this to be printed with the number of iterations:
What I have :
Input variables:
xTensionLaminate = 1325
SigmaFail = xTensionLaminate*VF
σApplied = xTensionLaminate*0.25
VF = 0.6
then the program is steps:
1.Apply tension part of the cycle. The applied stress on the fibers is
σAppliedFibers = σApplied/VF
2.All fibers with strength less than SigmaAppliedFibers fail. The fraction of fibers that have failed are:[%][7]
FibersTensionFail1 = CDF[NormalDistribution[795, 50 ], σAppliedFibers]
3.Fraction of fibers that remain[%][8]
FibersTensionRemaining1 = 1 - FibersTensionFail1
4.The remaining fibers now are equally loaded by the new stress[Mpa]
σAppliedFibersNew = σAppliedFibers/(1 - FibersTensionFail1)
5.Repeat steps corresponding to equations [7][8] until either convergence of (FibersTensionFail1 = FibersTensionRemaining1)<1 or all fibers fail FibersTensionFail1=1
This iteration needs to be done until FibersTensionRemaining
and FibersTensionFail
are equal or either one equal to unity.
So I try to put this in a While
loop.
While[FibersTensionRemaining <= FibersTensionFail,
FibersTensionFail = CDF[NormalDistribution[795, 50 ], σAppliedFibers];
FibersTensionRemaining = 1 - FibersTensionFail;
σAppliedFibersNew = σAppliedFibers/(1 - FibersTensionFail)
My question here is that in the NormalDistribution the σAppliedFibers
variable changes at each iteration according to the formula σAppliedFibersNew = σAppliedFibers/(1 - FibersTensionFail)
so the new σAppliedFibers
comes back into FibersTensionFail = CDF[NormalDistribution[795, 50 ], σAppliedFibers];
where after doing this n number of times there should be a converge in FibersTensionRemaining
and FibersTensionFail
Please help on this as i cannot find the way
Thanks,
Nick
EDIT: Note: The name of the Variables are slightly changed here but are the same.
What I do as a code manually and I stop the calculation:
1st iteration:
AccountingForm[
FibersFailed1 =
CDF[NormalDistribution[795, 50 ], StressAppliedFibers1] , 30] = 0.0000005919095091896093
AccountingForm[FibersRemaining1 = 1 - FibersFailed1, 31] = 0.999999408090491
StressAppliedFibers2 = StressAppliedFibers/(1 - FibersFailed1) = 552.084
2nd iteration:
AccountingForm[
FibersFailed2 =
CDF[NormalDistribution[795, 50 ], StressAppliedFibers2], 30] = 0.000000591909509834259
AccountingForm[FibersRemaining2 = 1 - FibersFailed2, 30]=0.99999940809049
StressAppliedFibers3 = StressAppliedFibers/(1 - FibersFailed2)=552.084
3rd Iteration:
AccountingForm[
FibersFailed3 =
CDF[NormalDistribution[795, 50 ], StressAppliedFibers3] , 30]=0.0000005919095098342807
AccountingForm[FibersRemaining3 = 1 - FibersFailed3, 30]= 0.99999940809049
StressAppliedFibers4 = StressAppliedFibers/(1 - FibersFailed3)=552.084
4th Iteration:
AccountingForm[
FibersFailed4 =
CDF[NormalDistribution[795, 50 ], StressAppliedFibers4] , 30]=0.0000005919095098342807
AccountingForm[FibersRemaining4 = 1 - FibersFailed4, 30]= 0.99999940809049
StressAppliedFibers5 = StressAppliedFibers/(1 - FibersFailed4)=552.084
So what we can see here is that after the 3rd iteration the values remain the same no matter how many iterations are made again.
What I need to figure how to make the loop which will take these variables and change them until the values converge and then print the number of iterations and also the final value of The FibersRemaining
and StressAppliedFibers
. Simple yes but I do not know how to add to a loop changeable variables.
thanks
N
goto
. Try reworking your code usingWhile
$\endgroup$p=NestList[{CDF[NormalDistribution[795,50],#[[2]]],#[[2]]/(1-#[[1]])}&,{CDF[NormalDistribution[795,50],\[Sigma]AppliedFibers],\[Sigma]AppliedFibers},10^5];ListPlot[#,MaxPlotPoints->1000]&/@Transpose@p
$\endgroup$