How to automate the operation of calculix

I now have many input files that need to be submitted for calculations, and these files must be calculated individually. My operating system is Windows 11, and I have two questions that I am quite confused about:

  1. How to use code to automatically submit input files to the calculix solver for computation.
  2. How to automatically read the specified value of each frd file and output it to a txt file.

The ideal process is: inp1 → frd1 → txt, inp2 → frd2 → txt, inp3 → frd3 → txt …
txt has only one number, and the next one will overwrite the previous one.

The first part is easy to do, a batch file should suffice if you want to submit multiple analyses in a sequence. The second part (automating results writing) is more tricky but cgx (GraphiX) may suffice:

1 Like

I also missed a step, and the specific method is as follows. I want to achieve automated operation of the following steps.

  1. Prepare 2 set of data files and name them as ex. step_1.inp and step_2.inp

  2. Copy step_1.inp to step.inp
    “step_1.inp” holds the original geometri & load for 1’st run

  3. Run ccx -i step

  4. Copy step.frd to step_1.frd
    “step.frd” holds output specified in the cards “*node file” & “*element file” for 1’st step

  5. Read step_1.frd to get sdv6 and send it to txt file.

  6. Copy step.rout to step.rin
    “step.rout” holds the stiffness matrice, strains & deformed geometri from first run

  7. Copy step_2.inp to step.inp
    “step_2.inp” holds load for 2’nd run expected to be added to 1’st result

  8. Run ccx -i step

  9. Copy step.frd to step_2.frd
    “step.frd” holds output specified in the cards “*node file” & “*element file” for 2’nd step

  10. Read step_2.frd to get sdv6 and send it to txt file.

Hi,
I usually use python for that kind of automation. Assuming you have the two files step_1.inp and step_2.inp, you could try something like

import os
import shutil

# step 2, copy step_1.inp to step.inp
shutil.copyfile("step_1.inp", "step_2.inp")

# step 3, run calculix
os.system("ccx -i step")

# step 4, copy step.frd to step_1.frd
shutil.copyfile("step.inp", "step_1.frd")

# step 5 get sdv6 from step_1.frd
with open("step_1.frd", "r") as f:
    content = f.readlines()
sdv6 = []
for line in content:
    # I actually don't have a file and don't know how to detect this exactly
    if "XXX" in line:
        sdv6 += [line]
with open("step_1.txt", "w") as f:
    for line in sdv6:
        f.write(line)

# step 6, copy step.out to step.rin
shutil.copy("step.out", "step.rin")

# step 7, copy step_2 to step
shutil.copy("step_2.inp", "step.inp")

# step 8, run ccx
os.system("ccx -i step")

# step 9, copy step.frd to step_2.frd
shutil.copy("step.frd", "step_2.frd")

# step 10, read step_2.frd to get sdv6 and save as txt
# same as step 5

Warning: typos included in the above script. I just wrote this down without checking every detail. There is also something you have to adapt at step 5 and 10 as I dont know exactly how to detect the sdv6 data.

1 Like

Thanks,I will have try.

Windows lacks most of the tools natively available on UNIX-like operating systems, like sed, awk and make.

So installing a powerful scripting language like Python is a good idea.
The code that @Nobody-86 provides is a good start.

The format of frd files is defined in the chapter “Result Format” in the manual for cgx, in the form of FORTRAN format strings.

Nodal or element data is found on lines starting with " -1".
Unfortunately the data fields are run together, so a simple str.split() does not work.

After having extracted node-related data from ascii frd files multiple times in Python, I consolidated that code into a module and program calculix-frdconvert, available on github. You might find that useful.

1 Like