General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

How to define a film coefficient table by command line in Ansys Mechanical?

TAGGED: 

    • Ramiro MENA
      Subscriber

      Dear Ansys Learning Forum Team,

      I am writing an Iron Python script on Ansys Mechanical for a thermal problem.

      When a convection load is created (A), in order to define the Film coefficient (B), I need to perform a click on the dropdown list and then, I can select the Tabular option (C). (See attached figure).

      However, if I want to automatize this task, I can not do it manually. Therefore, my question is how to define a film coefficient table by command line? (i.e. to perform task (C) ).

      Any suggestion will be appreciated.

      Best regards,

      Ramiro M.

      Ps: After reading the Ansys ACT manual, it says

      Field Convection.FilmCoefficient { get; }

      Gets the FilmCoefficient.

      Remarks

      This property cannot be set. When one wants to change its value, one should operate on the returned Field object, either on its inputs or on its output variables .


    • Ashish Khemka
      Forum Moderator
      nnPlease refer to the following link for the command used:nnnnRegards,nAshish Khemkann/forum/discussion/3978/how-to-access-the-ansys-online-helpn
    • Erik Kostson
      Ansys Employee
      Not sure if you want a command snippet or act call to define a convection with time dependent film coefficient.nnFor the later part, say we add a Convection via ACT :nConv=ExtAPI.DataModel.Project.Model.Analyses[0].AddConvection()nnThe field you mentioned in your post (Convection.FilmCoefficient { get; }), we can use to get, but we need to use Inputs and Output to actually set them.nnSo to set them: (you would need to change this as needed in your code, but at least you can see how it can be done)n---nConv.FilmCoefficient.Inputs[0].DiscreteValues=[Quantity('0[s]'),Quantity('0.5[s]'),Quantity('1[s]')]nConv.FilmCoefficient.Output.DiscreteValues=[Quantity('0[W m^-1 m^-1 C^-1]'),Quantity('99[W m^-1 m^-1 C^-1]'),Quantity('999[W m^-1 m^-1 C^-1]')]nn---Hope this helpsErik
    • Ramiro MENA
      Subscriber
      Dear @akhemka nThank you for your reply. I did not consider (yet) the option of including an APDL command on my script. At the moment I am working with Ansys ACT and its snippets (but I am sure I will need APDL sooner or later).n
    • Ramiro MENA
      Subscriber
      Dear @ekostson nThank you for your reply. Now I am able to define and populate a table automatically on my script.nHowever, now I have the following questions (just for curiosity):nWhen the Inputs are defined in the line: Conv.FilmCoefficient.Inputs[0].DiscreteValues=[Quantity('0[s]'),Quantity('0.5[s]'),Quantity('1[s]')] you are defining a time dependent FilmCoefficient. So, if you want to define a temperature dependent FilmCoefficient, first I tried to change only the units from time to temperature, but it didn't work, so, I opted to use: Conv.IndependentVariable = LoadVariableVariationType.Temperature, then I proceeded to define the film Coefficient values (that now depend on Temperature): Conv.FilmCoefficient.Output.DiscreteValues=[Quantity('0[W m^-1 m^-1 C^-1]'),Quantity('99[W m^-1 m^-1 C^-1]'),Quantity('999[W m^-1 m^-1 C^-1]')] . So, my question is if there is a way to define in advance the temperature as an indepentent variable?nIf I have a list only with numerical values that will be used to populate my table, first I need to create a new list with the Ansys syntax [Quantity('value[unit]', Quantity('value[unit]',...,Quantity('value[unit]')]. If the table has a few values, you can do it manually, but if you have a big table it starts to be a little bit cumbersome. So, I was able to define a function to populate the table (see the attached code below). However, I would be interested to know if there is a more efficient method to load the data (maybe to import the temperature dependent table in a XML file?)nn#Temperature and FilmCoefficient values for air (data) nT_air = [10,20,30] #Temperature values in [C]nh_air = [5,7.5,10] #Film coefficient values in [W/m2K]nndef Temperature_FilmCoefficient_values(T,h):n#Function to write a list with the Ansys sintax [Quantity('value[unit]', Quantity('value[unit]',...,Quantity('value[unit]')]n#Input: T (list) numerical values of the Temperature in [C]n#       h (list) numerical values of the FilmCoefficient in [W/m2K]n#Output T_list (list) Temperature with the Ansys Syntaxn        h_list (list) FilmCoefficient with the Ansys Syntax n   T_list = []n   h_list = []n   for i in range(len(T)):n       T_list.append(Quantity(str(T[i])+'[s]'))n       h_list.append(Quantity(str(h[i]) + '[W m^-1 m^-1 C^-1]'))n   return T_list, h_listnn#Ansys codenConv = Model.Analyses[0].AddConvection() #Add convection loadnConv.FilmCoefficient.Inputs[0].DiscreteValues = T_list #Populate the table with T_listnConv.IndependentVariable = LoadVariableVariationType.Temperature #Define temperature as the independent variablenConv.FilmCoefficient.Output.DiscreteValues = h_list #Populate the table with h_listnConv.AmbientTemperature.Output.SetDiscreteValue(0, Quantity(26.85, C)) #Set the ambient temperaturennAgain, thank you in advance for your help and guidance.nBest regards,nRamiro M.n
    • makinse
      Subscriber

      Please, can you explain how to define a film coefficient using a function

    • Alonso Sycorax
      Subscriber

      I cannot clear all. Maybe i need time to practice it.

      Thanks for sharing

    • Alonso Sycorax
      Subscriber

      /forum/forums/topic/how-to-access-the-ansys-online-help/ dino game

      Waiting for the answer too

    • makinse
      Subscriber

      Do you need help inputting the film coefficient function too?

Viewing 8 reply threads
  • The topic ‘How to define a film coefficient table by command line in Ansys Mechanical?’ is closed to new replies.