User:Kate Racaza/test page: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:


==Prerequisites==
==Prerequisites==
In this tutorial, you'll use a Windows Form application to create a button that, when clicked, analyzes a Weibull++ data set and displays the resulting plot. Before you begin, be sure to create a Windows Form Application project, and insert a button and a picturebox control to the form. You can rename the button to "Create Plot," if desired.
In this tutorial, you'll use a Windows Form application to create a button that, when clicked, analyzes a Weibull++ data set and displays the resulting plot. Before you begin, be sure to create a Windows Form Application project, and add a '''button''' and a '''picturebox''' control to the form. You can rename the button to "Create Plot," if desired.


Need help with creating Windows Forms? See this [https://msdn.microsoft.com/en-us/library/b201w61t%28v=vs.100%29.aspx Microsoft tutorial].
Need help with creating Windows Forms? See this [https://msdn.microsoft.com/en-us/library/b201w61t%28v=vs.100%29.aspx Microsoft tutorial].


==Tutorial: W++/ALTA Plots ==
==Tutorial: W++/ALTA Plots ==
The following example demonstrates how to use the Synthesis API to create a plot and display it in a Windows application. A discussion of the example follows.  
The following example demonstrates how to use the Synthesis API to create a Weibull++ probability plot and display it in a Windows application. A discussion of the example follows.  


  '''VB.NET'''
  '''VB.NET'''
Line 43: Line 43:
     WPlot.AddDataset(WDS)
     WPlot.AddDataset(WDS)
   
   
  {{APIComment|'Create a probability plot and display it in the picturebox.}}
  {{APIComment|'Create a probability plot and display it in the PictureBox.}}
   PictureBox1.Image =WPlot.CreatePlot(WAPlotType.Probability)
   PictureBox1.Image = WPlot.CreatePlot(WAPlotType.Probability)
   PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
   PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
    
    
Line 53: Line 53:
==Discussion==
==Discussion==


The [[ALTAStressProfile_Class|ALTAStressProfile]] class represents a time-dependent stress profile. In this example, the stresses are increased in a stepwise fashion. The <code>RepeatCycle</code> property is set to False, indicating that all times after the last segment will use the stress value defined in the last segment.
The Synthesis API can create plots only from analyzed data sets. In this example, the first three sections of code demonstrate how to create and analyze a simple Weibull++ data set (for a full discussion, see [[Perform_Life_Data_Analysis_on_External_Data_Source|this tutorial]]).


{{APIComment|'Declare a new stress profile and define its segments.}}  
  {{APIComment|'Create a Weibull++ data set.}}  
  {{APIPrefix|Dim}} sp {{APIPrefix|As New}} ALTAStressProfile
    {{APIPrefix|Dim}} WDS {{APIPrefix|As New}} WeibullDataSet
  sp.AddSegment(200, 125)  
    WDS.AddFailure(16, 1)
  sp.AddSegment(300, 175)
    WDS.AddFailure(34, 1)
  sp.AddSegment(350, 200)
    WDS.AddFailure(53, 1)
  sp.AddSegment(375, 250)
    WDS.AddFailure(75, 1)
  sp.RepeatCycle = False
    WDS.AddFailure(93, 1)
    WDS.AddSuspension(120, 5) 
  {{APIComment|'Analyze the data set using the 2-parameter Weibull distribution and}}
  {{APIComment|'the RRX analysis method. Keep all other analysis settings at default.}}
    WDS.AnalysisSettings.Distribution = WeibullSolverDistribution.Weibull
    WDS.AnalysisSettings.Parameters = WeibullSolverNumParameters.MS_2Parameter
    WDS.AnalysisSettings.Analysis = WeibullSolverMethod.RRX
  {{APIComment|'Analyze the data set.}}
    WDS.Calculate()


Next, create an ALTA data set by declaring a new [[ALTADataSet Class|ALTADataSet]] object, and then using the [[ALTADataSet.AddStressProfile|AddStressProfile]] method to associate the stress profile with the object.  
The [[WAPlots Class|WAPlots]] object represents a plot based on the fitted model of a Weibull++ or ALTA data set. Use the [[WAPlots.AddDataset|AddDataset]] method to assign the data set (in this case, a WeibullDataSet object) to the plot.  


{{APIComment|'Declare a new ALTADataSet object.}}  
  {{APIComment|'Declare a new WAPlots object.}}
  {{APIPrefix|Dim}} ADS {{APIPrefix|As New}} ALTADataSet
    {{APIPrefix|Dim}} WPlot {{APIPrefix|As New}} WAPlots
 
   
  {{APIComment|'Assign the stress profile to the data set.}}
  {{APIComment|'Add the analyzed data set to the plot.}}
  ADS.AddStressProfile(sp)
    WPlot.AddDataset(WDS)
 
Use the [[ALTADataSet.AddStressDefinition|AddStressDefinition]] method to define the name, stress transformation and use stress level of the stress profile.
 
{{APIComment|'The stress profile uses the logarithmic (power LSR) stress transformation}}
{{APIComment|'and has a use stress level &#61; 100.}}
  ADS.AddStressDefinition({{APIString|"Stress1"}}, ALTASolverLSR.Power, 100)
 
The data set can contain failures, suspensions or interval data. The following example shows how to use the [[ALTADataSet.AddFailure|AddFailure]] method and [[ALTADataSet.AddSuspension|AddSuspension]] method to add the stress profile to the data points.
 
{{APIComment|'Add the failure times to the data set.}}
  ADS.AddFailure(252, 1, sp)
  ADS.AddFailure(280, 1, sp)
  ADS.AddFailure(320, 1, sp)
  ADS.AddFailure(335, 1, sp)
  ADS.AddFailure(354, 1, sp)
  ADS.AddFailure(361, 1, sp)
  ADS.AddFailure(362, 1, sp)
  ADS.AddFailure(368, 1, sp)
   
{{APIComment|'Add the suspensions to the data set.}}
  ADS.AddSuspension(328, 1, sp) 
  ADS.AddSuspension(375, 3, sp)  
 
The <code>AnalysisSetting</code> property returns an [[ALTAAnalysisOptions Class|ALTAAnalysisOptions]] object, which represents the analysis settings of the data set. In the following example, we use the <code>ModelType</code> and <code>Distribution</code> properties of the object to specify the life-stress relationship and distribution.


{{APIComment|'Use the cumulative damage - Weibull model to analyze the data set.}}
Use the [[WAPlots.CreatePlot|CreatePlot]] method to create the plot. To display the plot, assign it to the <code>Image</code> property of the PictureBox. The <code>SizeMode</code> property is optional; it resizes the PictureBox to fit the image.  
{{APIComment|'Keep all other analysis settings at default.}}
  ADS.AnalysisSettings.ModelType = ALTASolverModel.CumDamage
  ADS.AnalysisSettings.Distribution = ALTASolverDistribution.Weibull
 
Use the [[ALTADataSet.Calculate|Calculate]] method to analyze the data set. The method returns a message box that shows the estimated parameters of the model, based on the settings specified in the <code>AnalysisSettings</code> property.
 
{{APIComment|'Analyze the data set.}}
  ADS.Calculate()
 
The <code>FittedModel</code> property gets a [[CModel Class|cModel]] object that represents the fitted model of the analysis. From the model, you can calculate useful metrics such as reliability, failure rate, mean time, etc. In this example, we use the [[CModel.Time|cModel.Time]] method to calculate for the B1 life.
 
{{APIComment|'Calculate the B1 life and display the result.}}
  {{APIPrefix|Dim}} r {{APIPrefix|As}} Double
  r = ADS.FittedModel.Time(.99)
  MsgBox({{APIString|"B1 Life: "}} & r)
 
==Notes==
For analyses that require multiple stress profiles, the number of stress definitions must be equal to the number of stress profiles used in the analysis. For example:
 
{{APIComment|'Define two stress profiles.}}
  {{APIPrefix|Dim}} SP1 {{APIPrefix|As New}} ALTAStressProfile
  {{APIPrefix|Dim}} SP2 {{APIPrefix|As New}} ALTAStressProfile
{{APIComment|...}}
   
   
  {{APIComment|'Assign the stress profiles to a data set.}}  
  {{APIComment|'Create a probability plot and display it in the PictureBox.}}
   {{APIPrefix|Dim}} ADS {{APIPrefix|As New}} ALTADataSet
   PictureBox1.Image = WPlot.CreatePlot(WAPlotType.Probability)
  ADS.AddStressProfile(SP1)
   PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
  ADS.AddStressProfile(SP2)
{{APIComment|'Define the stress transformations and use stress levels.}}
  ADS.AddStressDefinition({{APIString|"Stress1"}}, ALTASolverLSR.Arrhenius, 100)
   ADS.AddStressDefinition({{APIString|"Stress2"}}, ALTASolverLSR.Power, 4)


You can then use the overloaded methods to add the stress profiles to the data points:
{{APIComment|...}}
{{APIComment|'Add failure times.}}
  ADS.AddFailure(171, 1, SP1, SP2)
  ADS.AddFailure(174, 1, SP1, SP2)
{{APIComment|...}}


===References===
==References==
*[[ALTAStressProfile Class]]
*[[WAPlots Class]]
*[[ALTADataSet Class]]
**[[WAPlots.AddDataset|WAPlots.AddDataset Method]]
*[[ALTADataSet.AddStressProfile|ALTADataSet.AddStressProfile Method]]
**[[WAPlots.CreatePlot|WAPlots.CreatePlot Method]]
*[[ALTADataSet.AddStressDefinition|AddStressDefinition Method]]
*[[ALTADataSet.AddFailure|ALTADataSet.AddFailure Method]]
*[[ALTADataSet.AddSuspension| ALTADataSet.AddSuspension Method]]
*[[ALTADataSet.Calculate|ALTADataSet.Calculate Method]]
*[[ALTAAnalysisOptions Class]]
*[[CModel Class|cModel Class]]

Revision as of 23:12, 12 May 2016

DRAFT

APIWiki.png


<< Back to Tutorials Main Page

xxx

Prerequisites

In this tutorial, you'll use a Windows Form application to create a button that, when clicked, analyzes a Weibull++ data set and displays the resulting plot. Before you begin, be sure to create a Windows Form Application project, and add a button and a picturebox control to the form. You can rename the button to "Create Plot," if desired.

Need help with creating Windows Forms? See this Microsoft tutorial.

Tutorial: W++/ALTA Plots

The following example demonstrates how to use the Synthesis API to create a Weibull++ probability plot and display it in a Windows application. A discussion of the example follows.

VB.NET

Imports SynthesisAPI 

Module Module1
   Sub Main()
 
  'Create a Weibull++ data set.  
   Dim WDS As New WeibullDataSet
   WDS.AddFailure(16, 1)
   WDS.AddFailure(34, 1)
   WDS.AddFailure(53, 1)  
   WDS.AddFailure(75, 1)
   WDS.AddFailure(93, 1)
   WDS.AddSuspension(120, 5)   

  'Analyze the data set using the 2-parameter Weibull distribution and  
  'the RRX analysis method. Keep all other analysis settings at default. 
   WDS.AnalysisSettings.Distribution = WeibullSolverDistribution.Weibull
   WDS.AnalysisSettings.Parameters = WeibullSolverNumParameters.MS_2Parameter
   WDS.AnalysisSettings.Analysis = WeibullSolverMethod.RRX
 
  'Analyze the data set. 
   WDS.Calculate()

  'Declare a new WAPlots object. 
   Dim WPlot As New WAPlots

  'Add the analyzed data set to the plot. 
   WPlot.AddDataset(WDS)

 'Create a probability plot and display it in the PictureBox. 
  PictureBox1.Image = WPlot.CreatePlot(WAPlotType.Probability)
  PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
 
   End Sub
End Module


Discussion

The Synthesis API can create plots only from analyzed data sets. In this example, the first three sections of code demonstrate how to create and analyze a simple Weibull++ data set (for a full discussion, see this tutorial).

  'Create a Weibull++ data set.  
   Dim WDS As New WeibullDataSet
   WDS.AddFailure(16, 1)
   WDS.AddFailure(34, 1)
   WDS.AddFailure(53, 1)  
   WDS.AddFailure(75, 1)
   WDS.AddFailure(93, 1)
   WDS.AddSuspension(120, 5)   

  'Analyze the data set using the 2-parameter Weibull distribution and  
  'the RRX analysis method. Keep all other analysis settings at default. 
   WDS.AnalysisSettings.Distribution = WeibullSolverDistribution.Weibull
   WDS.AnalysisSettings.Parameters = WeibullSolverNumParameters.MS_2Parameter
   WDS.AnalysisSettings.Analysis = WeibullSolverMethod.RRX

  'Analyze the data set. 
   WDS.Calculate()

The WAPlots object represents a plot based on the fitted model of a Weibull++ or ALTA data set. Use the AddDataset method to assign the data set (in this case, a WeibullDataSet object) to the plot.

  'Declare a new WAPlots object. 
   Dim WPlot As New WAPlots

  'Add the analyzed data set to the plot. 
   WPlot.AddDataset(WDS)

Use the CreatePlot method to create the plot. To display the plot, assign it to the Image property of the PictureBox. The SizeMode property is optional; it resizes the PictureBox to fit the image.

 'Create a probability plot and display it in the PictureBox. 
  PictureBox1.Image = WPlot.CreatePlot(WAPlotType.Probability)
  PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize


References