Difference between revisions of "Perform Accelerated Life Testing Data Analysis with Stress Profiles/VBA"

From ReliaWiki
Jump to navigation Jump to search
(Created page with '{{Template:API}} ==Tutorial: Accelerated Life Testing Data Analysis - Stress Profiles == Below is the VBA version of the [[Perform_Accelerated_Life_Testing_Data_Analysis_with_St…')
 
 
Line 8: Line 8:
 
  {{APIPrefix|Sub}} Main()
 
  {{APIPrefix|Sub}} Main()
 
    
 
    
   {{APIComment|'Declare a new stress profile and define its segments.}}  
+
   {{APIComment|'Declare a new stress profile and define its properties.}}  
     {{APIPrefix|Dim}} sp {{APIPrefix|As New}} ALTAStressProfile
+
     {{APIPrefix|Dim}} myProfile {{APIPrefix|As New}} cProfile
     {{APIPrefix|Call}} sp.AddSegment(200, 125)
+
     myProfile.Name = {{APIString|"StressProfile"}}
    {{APIPrefix|Call}} sp.AddSegment(300, 175)
+
     myProfile.ProfileType = ProfileTypeEnum_Stress
     {{APIPrefix|Call}} sp.AddSegment(350, 200)
+
     myProfile.IsCyclical = False
    {{APIPrefix|Call}} sp.AddSegment(375, 250)
 
     sp.RepeatCycle = False
 
 
   
 
   
 +
  {{APIComment|'Define four segments for the stress profile.}}
 +
    {{APIPrefix|Dim}} segment {{APIPrefix|As}} ProfileSegment
 +
    {{APIPrefix|Dim}} listofsegments(3) {{APIPrefix|As}} ProfileSegment
 +
 
 +
    {{APIPrefix|Set}} segment = {{APIPrefix|New}} ProfileSegment
 +
    segment.SegmentEnd = 200
 +
    segment.Value = 124
 +
    {{APIPrefix|Set}} listofsegments(0) = segment
 +
 
 +
    {{APIPrefix|Set}} segment = {{APIPrefix|New}} ProfileSegment
 +
    segment.SegmentEnd = 300
 +
    segment.Value = 175
 +
    {{APIPrefix|Set}} listofsegments(1) = segment
 +
 
 +
    {{APIPrefix|Set}} segment = {{APIPrefix|New}} ProfileSegment
 +
    segment.SegmentEnd = 350
 +
    segment.Value = 200
 +
    {{APIPrefix|Set}} listofsegments(2) = segment
 +
 
 +
    {{APIPrefix|Set}} segment = {{APIPrefix|New}} ProfileSegment
 +
    segment.SegmentEnd = 375
 +
    segment.Value = 250
 +
    {{APIPrefix|Set}} listofsegments(3) = segment
 +
 +
  {{APIComment|'Add the segments to the stress profile.}}
 +
    myProfile.SetSegments listofsegments
 +
 
 
   {{APIComment|'Declare a new ALTADataSet object.}}  
 
   {{APIComment|'Declare a new ALTADataSet object.}}  
 
     {{APIPrefix|Dim}} ADS {{APIPrefix|As New}} ALTADataSet
 
     {{APIPrefix|Dim}} ADS {{APIPrefix|As New}} ALTADataSet
 
   
 
   
 
   {{APIComment|'Assign the stress profile to the data set.}}  
 
   {{APIComment|'Assign the stress profile to the data set.}}  
     {{APIPrefix|Call}} ADS.AddStressProfile(sp)
+
     {{APIPrefix|Call}} ADS.AddStressProfile(myProfile)
 
   
 
   
 
   {{APIComment|'The stress profile uses the logarithmic (power LSR) stress transformation}}
 
   {{APIComment|'The stress profile uses the logarithmic (power LSR) stress transformation}}
Line 27: Line 52:
 
    
 
    
 
   {{APIComment|'Add the failure times to the data set.}}
 
   {{APIComment|'Add the failure times to the data set.}}
     {{APIPrefix|Call}} ADS.AddFailure_2(252, 1, sp)
+
     {{APIPrefix|Call}} ADS.AddFailure_2(252, 1, myProfile)
     {{APIPrefix|Call}} ADS.AddFailure_2(280, 1, sp)
+
     {{APIPrefix|Call}} ADS.AddFailure_2(280, 1, myProfile)
     {{APIPrefix|Call}} ADS.AddFailure_2(320, 1, sp)
+
     {{APIPrefix|Call}} ADS.AddFailure_2(320, 1, myProfile)
     {{APIPrefix|Call}} ADS.AddFailure_2(335, 1, sp)
+
     {{APIPrefix|Call}} ADS.AddFailure_2(335, 1, myProfile)
     {{APIPrefix|Call}} ADS.AddFailure_2(354, 1, sp)
+
     {{APIPrefix|Call}} ADS.AddFailure_2(354, 1, myProfile)
     {{APIPrefix|Call}} ADS.AddFailure_2(361, 1, sp)
+
     {{APIPrefix|Call}} ADS.AddFailure_2(361, 1, myProfile)
     {{APIPrefix|Call}} ADS.AddFailure_2(362, 1, sp)
+
     {{APIPrefix|Call}} ADS.AddFailure_2(362, 1, myProfile)
     {{APIPrefix|Call}} ADS.AddFailure_2(368, 1, sp)
+
     {{APIPrefix|Call}} ADS.AddFailure_2(368, 1, myProfile)
 
      
 
      
 
   {{APIComment|'Add the suspensions to the data set.}}
 
   {{APIComment|'Add the suspensions to the data set.}}
     {{APIPrefix|Call}} ADS.AddSuspension_2(328, 1, sp)   
+
     {{APIPrefix|Call}} ADS.AddSuspension_2(328, 1, myProfile)   
     {{APIPrefix|Call}} ADS.AddSuspension_2(375, 3, sp)  
+
     {{APIPrefix|Call}} ADS.AddSuspension_2(375, 3, myProfile)  
 
    
 
    
 
   {{APIComment|'Use the cumulative damage - Weibull model to analyze the data set.}}
 
   {{APIComment|'Use the cumulative damage - Weibull model to analyze the data set.}}

Latest revision as of 18:42, 23 March 2017

APIWiki.png



Tutorial: Accelerated Life Testing Data Analysis - Stress Profiles

Below is the VBA version of the tutorial.

VBA

Sub Main()
 
  'Declare a new stress profile and define its properties.  
   Dim myProfile As New cProfile
   myProfile.Name = "StressProfile"
   myProfile.ProfileType = ProfileTypeEnum_Stress
   myProfile.IsCyclical = False

  'Define four segments for the stress profile. 
   Dim segment As ProfileSegment
   Dim listofsegments(3) As ProfileSegment
  
   Set segment = New ProfileSegment
   segment.SegmentEnd = 200
   segment.Value = 124
   Set listofsegments(0) = segment
  
   Set segment = New ProfileSegment
   segment.SegmentEnd = 300
   segment.Value = 175
   Set listofsegments(1) = segment
  
   Set segment = New ProfileSegment
   segment.SegmentEnd = 350
   segment.Value = 200
   Set listofsegments(2) = segment
  
   Set segment = New ProfileSegment
   segment.SegmentEnd = 375
   segment.Value = 250
   Set listofsegments(3) = segment

  'Add the segments to the stress profile. 
   myProfile.SetSegments listofsegments
 
  'Declare a new ALTADataSet object.  
   Dim ADS As New ALTADataSet

  'Assign the stress profile to the data set.  
   Call ADS.AddStressProfile(myProfile)

  'The stress profile uses the logarithmic (power LSR) stress transformation 
  'and has a use stress level = 100.  
   Call ADS.AddStressDefinition("Stress1", ALTASolverLSR_Power, 100)
 
  'Add the failure times to the data set. 
   Call ADS.AddFailure_2(252, 1, myProfile)
   Call ADS.AddFailure_2(280, 1, myProfile)
   Call ADS.AddFailure_2(320, 1, myProfile)
   Call ADS.AddFailure_2(335, 1, myProfile)
   Call ADS.AddFailure_2(354, 1, myProfile)
   Call ADS.AddFailure_2(361, 1, myProfile)
   Call ADS.AddFailure_2(362, 1, myProfile)
   Call ADS.AddFailure_2(368, 1, myProfile)
   
  'Add the suspensions to the data set. 
   Call ADS.AddSuspension_2(328, 1, myProfile)   
   Call ADS.AddSuspension_2(375, 3, myProfile) 
 
  'Use the cumulative damage - Weibull model to analyze the data set. 
  'Keep all other analysis settings at default. 
   ADS.AnalysisSettings.ModelType = ALTASolverModel_CumDamage
   ADS.AnalysisSettings.Distribution = ALTASolverDistribution_Weibull
 
  'Analyze the data set. 
   Call ADS.Calculate()

  'Calculate the B1 life and display the result. 
   Dim r As Double
   r = ADS.FittedModel.Time(.99)
   MsgBox("B1 Life: " & r)

End Sub