CModel.SetUseStress: Difference between revisions

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




<onlyinclude>For ALTA models only. Sets the use stress level for one or multiple stresses of a [[CModel Class|cModel]] object.</onlyinclude>
<onlyinclude>For ALTA models only. Sets the use stress level for one or multiple stresses for subsequent calculations.</onlyinclude>


This method does not apply to published models, which are model resources that have been published from and are associated with an existing analysis/data source.
== Syntax ==
== Syntax ==
'''VBA'''
'''.SetUseStress'''(''Index'', ''StressValue'')
'''.SetUseStress_2'''(''StressValues()'')
'''VB.NET'''
   
   
  '''.SetUseStress'''(''Index'', ''StressValue'')
  '''.SetUseStress'''(''Index'', ''StressValue'')
Line 28: Line 21:


== Example ==
== Example ==
{{APIComment|'Declare a new repository connection object. See [[Repository Class|Repository]].}}
This example assumes that a model with ID #47 exists in the first available project of a repository.
  Dim MyRepository As New Repository
 
 
'''VB.NET'''
  {{APIComment|'Connect to the Synthesis repository.}}
  Dim Success As Boolean = False
  {{APIComment|'Add code to connect to a Synthesis repository.}}
  Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
 
   {{APIComment|...}}
{{APIComment|'Get the list of projects in the connected repository.}}
   Dim ListOfModels() As [[NameIdPair Class|NameIdPair]]
  ListOfModels = MyRepository.GetAllModelsInfo()
 
{{APIComment|'Select the ID of the model and retrieve it. In this example, the first model is used.}}
  Dim AModel as cModel
  AModel = MyRepository.GetModel(ListOfModels(0).ID)
    
    
{{APIComment|'Get ALTA model #47 from project #1.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.Project.SetCurrentProject(1) 
  AModel = MyRepository.Model.GetModel(47)
  {{APIComment|'Get the number of stresses in the model.}}
  {{APIComment|'Get the number of stresses in the model.}}
   Dim MyNumStresses As Integer
   {{APIPrefix|Dim}} MyNumStresses {{APIPrefix|As Integer}}
   MyNumStresses = AModel.NumStresses
   MyNumStresses = AModel.NumStresses  
 
  {{APIComment|'Create an array and specify the use stress values for each of the stresses.}}
  {{APIComment|'Assume that the number of stresses in this example is 2.}}
  {{APIComment|'Assume the MyNumStresses in this example is 2.}}
  {{APIComment|'Set the use stress values for each of the stresses.}}
   Dim UseStressArray(MyNumStresses - 1) As Double
   {{APIPrefix|Dim}} UseStressArray(MyNumStresses-1) {{APIPrefix|As Double}}
   UseStressArray(0) = 500
   UseStressArray(0) = 500
   UseStressArray(1) = 750
   UseStressArray(1) = 750
 
  {{APIComment|'Set the UseStress for the model.}}
  {{APIComment|'Set the use stress values for the model.}}  
   AModel.SetUseStress(UseStressArray)
   AModel.SetUseStress(UseStressArray)
{{APIComment|'Calculations using the specified stress values are now possible. For example,}}
{{APIComment|'the following code returns the model's reliability at 100 hrs}}
{{APIComment|'at the specified use stress levels.}}
  {{APIPrefix|Dim}} ResultValue {{APIPrefix|As Double}}
  ResultValue = AModel.Reliability(100)

Revision as of 18:07, 2 October 2015

Template:InProgress

APIWiki.png


Member of: SynthesisAPI9.cModel


For ALTA models only. Sets the use stress level for one or multiple stresses for subsequent calculations.

Syntax

.SetUseStress(Index, StressValue)
.SetUseStress(StressValues())

Parameters

Index

Required. Integer. The 0-based index of the stress for which the use stress level will be updated.

StressValue

Required. Double. The value to use for the use stress level.

StressValues()

Required. Double. An array of new use stress values that correspond to the array of stresses in the model (e.g., the first stress value will become the use stress level for the first stress).


Example

This example assumes that a model with ID #47 exists in the first available project of a repository.

VB.NET

 'Add code to connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  ... 

 
 'Get ALTA model #47 from project #1. 
 Dim AModel As cModel
 MyRepository.Project.SetCurrentProject(1)  
 AModel = MyRepository.Model.GetModel(47)

 'Get the number of stresses in the model. 
 Dim MyNumStresses As Integer
 MyNumStresses = AModel.NumStresses 

 'Assume that the number of stresses in this example is 2. 
 'Set the use stress values for each of the stresses. 
 Dim UseStressArray(MyNumStresses-1) As Double
 UseStressArray(0) = 500
 UseStressArray(1) = 750

 'Set the use stress values for the model.  
 AModel.SetUseStress(UseStressArray)

 'Calculations using the specified stress values are now possible. For example, 
 'the following code returns the model's reliability at 100 hrs 
 'at the specified use stress levels. 
 Dim ResultValue As Double
 ResultValue = AModel.Reliability(100)