Download (right-click and "save as")

# @author: hkim
# @version: 1
# @description: test
# @keywords: python, object type, test

#  className can be relative to the wrapper's folder or absolute path
#  "classes/Wing.java#Wing"
#  "C:/<User_DIR>/Application Data/Phoenix Integration/AServer<VERSION>/analyses/wrappers/classes/Wing.java#Wing"
#  "file:///C:/<User_DIR>/Application Data/Phoenix Integration/AServer<VERSION>/analyses/wrappers/classes/Wing.java#Wing"

variable: wingInput    object input   className="./classes/Wing.java#Wing"
variable: wingOutput   object output  className="./classes/Wing.java#Wing"
variable: wingArea     double output
variable: aspectRatio  double output


# ------------------------------------------
script: language="python"

import math
def run():
   rootChord = wingInput.getDoubleMemberValue("rootChord")
   tipChord =  wingInput.getDoubleMemberValue("tipChord")
   halfSpan =  wingInput.getDoubleMemberValue("halfSpan")

   wingArea0 = halfSpan*(rootChord + tipChord)
   aspectRatio0 = 4*halfSpan*halfSpan/wingArea0

   #copy values from wingInput to wingOutput. Alternatively use toXML()/fromXML()
   #wingOutput.fromXML(wingInput.toXML())

   wingOutput.setDoubleMemberValue("rootChord", wingInput.getDoubleMemberValue("rootChord"))
   wingOutput.setDoubleMemberValue("tipChord", wingInput.getDoubleMemberValue("tipChord"))
   wingOutput.setDoubleMemberValue("halfSpan", wingInput.getDoubleMemberValue("halfSpan"))
   wingOutput.setDoubleMemberValue("sweep", wingInput.getDoubleMemberValue("sweep"))
   wingOutput.setDoubleMemberValue("airfoil.thickness", wingInput.getDoubleMemberValue("airfoil.thickness"))
   wingOutput.setDoubleMemberValue("airfoil.LERadius", wingInput.getDoubleMemberValue("airfoil.LERadius"))

   # call methods
   wingArea1 = wingOutput.callMethod("getWingArea")
   aspectRatio1 = wingOutput.callMethod("getAspectRatio")

   # compare results
   assert (math.fabs(wingArea0 - wingArea1) < 1.e-10)
   assert (math.fabs(aspectRatio0 - aspectRatio1) < 1.e-10)

   wingArea.setValue(wingArea0)
   aspectRatio.setValue(aspectRatio0)