How to modify Electric Contact Conductance for 100+ thermal-electric contact regions?

Rohith Patchigolla
Rohith Patchigolla Member, Moderator, Employee Posts: 218
100 Comments 25 Answers Second Anniversary 25 Likes
✭✭✭✭

A customer’s model consists of 100+ thermal-electric contact regions. He wants to define their electric conductance as a function of temperature and use the same conductance-vs-temperature table for most of them. I know we can insert a command snippet with the ECC real constant as a function of temperature. What’s the best way to use the same table for a set of contact pairs? They are using 2023R2 but can upgrade to 24R1 if needed.

Answers

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 218
    100 Comments 25 Answers Second Anniversary 25 Likes
    ✭✭✭✭
    edited March 2024

    There are several ways to modify real constants for contacts. The below answer demonstrates how you can use Python Code object to do the same for selected set of contacts.

    Steps:
    1. Select the set of contacts that need to be modified --> RMB --> Group, and rename this group as “Modify ECC” (for example)
    2. RMB on Analysis --> Insert --> Python code object
    3. Use the below script to modify ECC for all contacts in the group.

    if solver_data.CurrentStep == 1:
        ContactGroup = DataModel.GetObjectsByName("Modify ECC")[0]
        ContactsToBeModified = ContactGroup.Children
        solver_input_file.WriteLine("/prep7")
        for cont in ContactsToBeModified:
            contID = solver_data.GetContactId(cont.ObjectId)
            targID = solver_data.GetContactTargetId(cont.ObjectId)
            solver_input_file.WriteLine("rmod," + str(contID) + ",19,%MyTCCVals% ! TCC")
            solver_input_file.WriteLine("rmod," + str(targID) + ",19,%MyTCCVals% ! TCC")
        solver_input_file.WriteLine("/solu")
    
    

    This will add the below APDL code snippet in the ds.dat (input file) when one hits solve in Mechanical (in the example, 2 contact objects were used and for each contact, real constant is modified for both pairs created in Mechanical by default). It is assumed that MyTCCVals table has already been defined via APDL command object under one of the contact objects or prior to Python Command object in Tree (table definition can also be included in the above python code snippet)

    ! ****** Begin Commands from Python Code ******
    /prep7
    rmod,4,19,%MyTCCVals% ! TCC
    rmod,5,19,%MyTCCVals% ! TCC
    rmod,8,19,%MyTCCVals% ! TCC
    rmod,9,19,%MyTCCVals% ! TCC
    /solu