General Mechanical

General Mechanical

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

Units are not consistent, when scripting in pyMechanical

    • cardiac.scripter
      Subscriber

      Hi, 

      I'm having a problem with my units. They are not staying consistent.

      I import my model as an .inp. The mesh is constructed in mm.

      # Import the model
      mimp=Model.GeometryImportGroup.AddModelImport()
      mimp.ModelImportSourceFilePath=input_file
      mimp.Import()

      I set the units:

      analysis = Model.AddStaticStructuralAnalysis()
      analysis.AutomaticTimeStepping = AutomaticTimeStepping.On
      analysis.InverseOption = True
      analysis.LargeDeflection = True

      ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardNMMdat

      But the mesh is imported as 5e4mm even though it should be in region 5e1mm.


      When I load the sampe input file in the GUI I don't get this problem. 



      When I load my pressure

      in MPa

      Pressure.Magnitude.Output.DiscreteValues = [Quantity("0 [Pa]"), Quantity("-1.0666e-002 [MPa]")]

      However when I display the BCs 



      It gives it in hbar.

      Therefore, I'm getting very different results to when I run in the GUI with the same input file. 
      Thanks in advance




    • Erik Kostson
      Ansys Employee

       

       

       

      Hi

       

      For the geometrey units issue. We need to set the units of the imported cdb file. See here where I have added that in the end of my post.

      https://discuss.ansys.com/discussion/4431/how-to-add-a-model-in-standalone-mechanical

       

      As for the hbar pressure issue, that comes from using the StandardNMMdat – I would suggest to use NMM or NMMton

      in ExtAPI.Application.ActiveUnitSystem = MechanicalUnitSystem.StandardNMMdat

      and that will have MPa units.

       

      To close of, I would suggest to post this type of questions (pymechanical and script type), in our dedicated script forum

      here: https://discuss.ansys.com/

       

      or if there is a bug/issue with pymech., then in github:

      https://github.com/ansys/pymapdl/issues

      All the best

      Erik

      PS: In the pressure load change unit to MPa from Pa see below marked:

      Pressure.Magnitude.Output.DiscreteValues = [Quantity(“0 [Pa]“), Quantity(“-1.0666e-002 [MPa]”)]

       

       

    • cardiac.scripter
      Subscriber

      Hi Erik, 

      That worked! Thanks for your help. 

      Yes I've seen this forum. However, I cant find the button for posting a new discussion topic aha. 

      Here is my home page:
      And thsi is when I open structures:



      Do I need to be approved before I can post? Or am I just being stupid and can't see the "Start New Discussion" button?

      Thanks in advance.

    • Erik Kostson
      Ansys Employee

      Hi

      What is your user name there and I can check why it has not been approved yet (like you say think it needs some approval)?

      All the best

      Erik

    • Erik Kostson
      Ansys Employee

      Hello

       

      Many thanks - you should be ok now (you should have recieved an email about it also).

      All the best

      Erik

    • cardiac.scripter
      Subscriber

      Sorted!

      • Erik Kostson
        Ansys Employee

         

        perfect – anything else (script related) post there and we will try to help.

         

Viewing 5 reply threads
  • The topic ‘Units are not consistent, when scripting in pyMechanical’ is closed to new replies.