File size: 6,917 Bytes
985c397 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | # ***************************************************************************
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
__title__ = "FreeCAD FEM calculix write inpfile step equation"
__author__ = "Bernd Hahnebach"
__url__ = "https://www.freecad.org"
import FreeCAD
def write_step_equation(f, ccxwriter):
f.write("\n{}\n".format(59 * "*"))
f.write("** At least one step is needed to run an CalculiX analysis of FreeCAD\n")
# build STEP line
step = "*STEP"
if ccxwriter.solver_obj.GeometricalNonlinearity == "nonlinear":
if ccxwriter.analysis_type in ["static", "thermomech"]:
# https://www.comsol.com/blogs/what-is-geometric-nonlinearity
step += ", NLGEOM"
elif ccxwriter.analysis_type == "frequency":
FreeCAD.Console.PrintMessage(
"Analysis type frequency and geometrical nonlinear "
"analysis are not allowed together, linear is used instead!\n"
)
if ccxwriter.solver_obj.IncrementsMaximum:
if ccxwriter.analysis_type in ["static", "thermomech", "electromagnetic"]:
step += f", INC={ccxwriter.solver_obj.IncrementsMaximum}"
# write STEP line
f.write(step + "\n")
# CONTROLS line
# all analysis types, ... really in frequency too?!?
if ccxwriter.solver_obj.IterationsControlParameterTimeUse:
f.write("*CONTROLS, PARAMETERS=TIME INCREMENTATION\n")
f.write(ccxwriter.solver_obj.IterationsControlParameterIter + "\n")
f.write(ccxwriter.solver_obj.IterationsControlParameterCutb + "\n")
# ANALYSIS type line
# analysis line --> analysis type
analysis_type = ""
if ccxwriter.analysis_type == "static":
analysis_type = "*STATIC"
elif ccxwriter.analysis_type == "frequency":
analysis_type = "*FREQUENCY"
elif ccxwriter.analysis_type == "thermomech":
if ccxwriter.solver_obj.ThermoMechType == "coupled":
analysis_type = "*COUPLED TEMPERATURE-DISPLACEMENT"
elif ccxwriter.solver_obj.ThermoMechType == "uncoupled":
analysis_type = "*UNCOUPLED TEMPERATURE-DISPLACEMENT"
elif ccxwriter.solver_obj.ThermoMechType == "pure heat transfer":
analysis_type = "*HEAT TRANSFER"
if ccxwriter.solver_obj.ThermoMechSteadyState:
analysis_type += ", STEADY STATE"
elif ccxwriter.analysis_type == "check":
analysis_type = "*NO ANALYSIS"
elif ccxwriter.analysis_type == "buckling":
analysis_type = "*BUCKLE"
elif ccxwriter.analysis_type == "electromagnetic":
if ccxwriter.solver_obj.ElectromagneticMode == "electrostatic":
analysis_type = "*HEAT TRANSFER, STEADY STATE"
# analysis line --> solver type
# https://forum.freecad.org/viewtopic.php?f=18&t=43178
if ccxwriter.solver_obj.MatrixSolverType == "default":
pass
elif ccxwriter.solver_obj.MatrixSolverType == "pastix":
analysis_type += ", SOLVER=PASTIX"
elif ccxwriter.solver_obj.MatrixSolverType == "pardiso":
analysis_type += ", SOLVER=PARDISO"
elif ccxwriter.solver_obj.MatrixSolverType == "spooles":
analysis_type += ", SOLVER=SPOOLES"
elif ccxwriter.solver_obj.MatrixSolverType == "iterativescaling":
analysis_type += ", SOLVER=ITERATIVE SCALING"
elif ccxwriter.solver_obj.MatrixSolverType == "iterativecholesky":
analysis_type += ", SOLVER=ITERATIVE CHOLESKY"
# analysis line --> automatic incrementation --> parameter DIRECT
# completely switch off ccx automatic incrementation
if not ccxwriter.solver_obj.AutomaticIncrementation:
if ccxwriter.analysis_type in ["static", "thermomech", "electromagnetic"]:
analysis_type += ", DIRECT"
# ANALYSIS parameter line
analysis_parameter = ""
if ccxwriter.analysis_type in ["static", "thermomech", "electromagnetic"]:
analysis_parameter = "{},{},{},{}".format(
ccxwriter.solver_obj.TimeInitialIncrement.getValueAs("s").Value,
ccxwriter.solver_obj.TimePeriod.getValueAs("s").Value,
ccxwriter.solver_obj.TimeMinimumIncrement.getValueAs("s").Value,
ccxwriter.solver_obj.TimeMaximumIncrement.getValueAs("s").Value,
)
elif ccxwriter.analysis_type == "frequency":
if (
ccxwriter.solver_obj.EigenmodeLowLimit == 0.0
and ccxwriter.solver_obj.EigenmodeHighLimit == 0.0
):
analysis_parameter = f"{ccxwriter.solver_obj.EigenmodesCount}\n"
else:
analysis_parameter = "{},{},{}\n".format(
ccxwriter.solver_obj.EigenmodesCount,
ccxwriter.solver_obj.EigenmodeLowLimit.getValueAs("Hz").Value,
ccxwriter.solver_obj.EigenmodeHighLimit.getValueAs("Hz").Value,
)
elif ccxwriter.analysis_type == "buckling":
analysis_parameter = "{},{}".format(
ccxwriter.solver_obj.BucklingFactors,
ccxwriter.solver_obj.BucklingAccuracy,
)
elif ccxwriter.analysis_type == "check":
analysis_parameter = ""
# write analysis type line, analysis parameter line
f.write(analysis_type + "\n")
f.write(analysis_parameter + "\n")
def write_step_end(f, ccxwriter):
f.write("\n{}\n".format(59 * "*"))
f.write("*END STEP\n")
|