Tabular load implemented from Python scripting

Luiza
Luiza Member Posts: 7
Name Dropper First Comment
**
edited October 2023 in General Language Questions

Hello everyone

I am working in Ansys Workbench 2022R2 in a coupled field module. I am adding loads from scripting. With a single value works easily, but I want to use tabular data for the load. Can i read tabular data for a load from scripting?
Can i set the step end time in analysis settings with input from csv?

Answers

  • Jaaroon
    Jaaroon Member Posts: 7
    Name Dropper First Comment
    **
    edited October 2023

    I assume you are trying to define a tabular load in Mechanical.

    If you provide load and related timestep values as lists this should not be a problem. It could be that you first have to define the number of timesteps in the analysis.

    Maybe my example for a pressure load below can help you:

    get analysis object

    Analysis = ExtAPI.DataModel.AnalysisByName("AnalysisName")

    define time steps for simulation

    Analysis.AnalysisSettings.NumberOfSteps = len(tsteps)-1
    for i,t in enumerate(tsteps,1):
    Analysis.AnalysisSettings.CurrentStepNumber = i
    Analysis.AnalysisSettings.StepEndTime = Quantity("{} [sec]".format(t))

    generate lists of tabular values

    time_vals = [Quantity("{} [sec]".format(t)) for t in tsteps]
    pressure_vals = [Quantity("{} [Pa]".format(p)) for p in pressure loads]

    define new pressure load for selection

    PressureLoad = Analysis.AddPressure()
    PressureLoad.Location = selection
    PressureLoad.Magnitude.Inputs[0].DiscreteValues = time_vals
    PressureLoad.Magnitude.Output.DiscreteValues = pressure_vals

  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 356
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭

    @Jaaroon @Luiza ,
    you can also make a 'Quantity' entity like this: Quantity(12,'N')
    you simply give it a number as arg1 and unit as string as arg2.