CN109240659A - A kind of Ansys Secondary based on Fortran Yu Matlab hybrid programming - Google Patents
A kind of Ansys Secondary based on Fortran Yu Matlab hybrid programming Download PDFInfo
- Publication number
- CN109240659A CN109240659A CN201710346108.XA CN201710346108A CN109240659A CN 109240659 A CN109240659 A CN 109240659A CN 201710346108 A CN201710346108 A CN 201710346108A CN 109240659 A CN109240659 A CN 109240659A
- Authority
- CN
- China
- Prior art keywords
- matlab
- ansys
- fortran
- user
- hybrid programming
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/20—Design optimisation, verification or simulation
- G06F30/23—Design optimisation, verification or simulation using finite element methods [FEM] or finite difference methods [FDM]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Evolutionary Computation (AREA)
- Geometry (AREA)
- Computer Security & Cryptography (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
A kind of Ansys Secondary based on Fortran Yu Matlab shuffling technology, belong to engineering machine emulation field, the present invention is firstly the need of configuration Matlab and Fortran hybrid programming environment and Ansys Secondary Development Work environment, then finite element model is created in Ansys according to Practical Project problem, and build Ansys second development interface, the exploitation of user's favorite subroutine is realized using Matlab and Fortran hybrid programming, last Ansys main program calls the finite element analysis of user's favorite subroutine progress model;The present invention provides a kind of new, effective implementation method for ANSYS secondary development, has expanded the Engineering Simulation function of Ansys.
Description
Technical field
The present invention relates to a kind of Ansys Secondary based on Matlab Yu Fortran hybrid programming, belongs to engineering
Computer Simulation field.
Background technique
Fortran is the computer advanced design language occurred earliest in the world, is widely used in scientific and engineering computing neck
Domain is suitble to solve all kinds of numerical problems, and program statement, close to nature mathematical formulae, execution efficiency is very high in computer, but
Its graphics capability is weaker, and inconvenient progress symbolic operation.
Matlab be MathWorks company of the U.S. produce business mathematics software, for algorithm development, data visualization,
The advanced techniques computational language and interactive environment that data analysis and numerical value calculate mainly include Matlab and Simulink two
It is most of.Matlab has many advantages, such as that visuality is strong, development efficiency is high, and in addition to this, Matlab additionally provides a large amount of engineerings
Common numerical value processing function and all kinds of tool boxes are calculated, other programming languages are compared, Matlab can be obviously shortened the development cycle.So
And as a kind of interpreted language, Matlab also has its shortcoming, for example speed is slower when Matlab execution Multiple Cycle, no
It is suitble to individually complete large complicated numerical value calculating.
Ansys is a powerful general finite meta software, it possesses powerful front and back processing and calculates analysis energy
Power, application range is extremely wide, has obtained the approval of numerous engineers and technicians and scientific research personnel.In addition to this, Ansys is additionally provided
Multiple secondary development tools have greatly expanded the function of Ansys.Common Ansys secondary development tool shares 4, respectively
It is APDL, UPFs, UIDL, Tcl/Tk.The present invention uses UPFs (user-programmable characteristic), it is used for from source code level pair
Ansys carries out secondary development.Ansys source code is write using Fortran language, causes the Ansys based on Fortran language
Secondary development has the deficiency for being difficult to realize symbolic operation, visualization capability difference.
Ansys itself has optimization module, the design and optimization of structure may be implemented, but its optimization ability is limited, in order to
Meet more optimization demands of user, Ansys also provides optimization subroutine interface simultaneously, and user can write certainly wherein
Define optimization algorithm.But for multi-parameter, the complicated optimum problem of multiple target, optimization algorithm is write using Fortran language and is opened
The hair period is longer, reduces the efficiency of Ansys secondary development.
Matlab and Fortran Mixed-Programming Technology has in engineering fields such as structure optimization, Reconnaissance Survey, water forces
It is widely applied, but not applied in the secondary development of finite element software.Therefore, it is necessary to study one kind to be based on Fortran
With the Ansys Secondary of Matlab hybrid programming, to solve some technical problems in Engineering Simulation at present.
Summary of the invention
In view of the defects existing in the prior art, the invention proposes a kind of based on Fortran and Matlab shuffling technology
Ansys Secondary, this method the advantages of both making full use of, improve Fortran and Matlab hybrid programming
Subproblem present in Ansys secondary development was carried out based on Fortran in the past, including is difficult to realize symbolic operation, visualization
Ability is poor, optimization ability is limited, development cycle length etc..
The technical scheme is that a kind of Ansys secondary development skill based on Matlab Yu Fortran hybrid programming
Art, it is characterised in that: the step of Fortran and Matlab shuffling carry out Ansys secondary development, including installation corresponding software
(Ansys, Visualstudio, Fortran, Matlab), the working environment for configuring Fortran and Ansys secondary development, match
Matlab and Fortran hybrid programming working environment are set, finite element model is created with Ansys, builds Ansys secondary development
Interface calls the sub- journey of user using Matlab and Fortran hybrid programming exploitation Ansys user's favorite subroutine, Ansys main program
Sequence carries out subsequent finite element method (fem) analysis.
Preferably, the installation corresponding software, it is contemplated that the compatibling problem between each software different editions, the present invention push away
Recommending each software installation version is Ansys14.5, Fortran11.1, Visualstudio2008, Matlab2012b.User can also
The Ansys version bought according to itself matched with reference to its user's favorite subroutine help document corresponding Fortran with
Visualstudio version.
Preferably, the working environment for configuring Fortran and Ansys secondary development is needed to compile, be connected and activation UPFs
(user-programmable characteristic);Three environmental variances are set first, are Path, Lib and include respectively;Then it will need to compile
User's favorite subroutine copy to ANSYS Inc v145 ANSYS custom user under intel file, it is then successively single
Beginning > all program > ANSYS14.5 > Utilities are hit, click ANS_ADMIN therein, then click Relink therein
ANSYS enters compiling interface, is finally compiled connection according to interface prompt, will appear after compiling successfully " LINK WAS
The prompt of SUCCESSFUL ".
Preferably, configuration Matlab and Fortran hybrid programming working environment key in life under Matlab command prompt
The source program name for enabling Mex and being aided with parameter-f and corresponding option file and needing to compile, format are as follows: Mex-f <
Matlab > bin optsfilename.bat filename.f, if environment configurations succeed, mex order will not return appoint
What information, is returned directly under Matlab command prompt.
Preferably, finite element model is created with Ansys, user establishes corresponding finite element mould according to Practical Project problem
Type.
Preferably, build the interface of Ansys secondary development, with realize the customized subprogram of user and Ansys main program it
Between data exchange and transmitting.
Preferably, Ansys user's favorite subroutine is developed using Matlab and Fortran hybrid programming, first statement Matlab
Interface (API) function, including Engine function and access function, definition pointer variable;Then start Matlab engine and create defeated
Fortran array is transferred in Matlab output matrix and the working space of Matlab is written by matrix out, needed for finally executing
Matlab program, calculated result is returned into Fortran user's favorite subroutine.
Preferably, user's favorite subroutine is called to carry out subsequent finite element method (fem) analysis, Ansys master in Ansys main program
The subroutine call Matlab program that program is edited using user come assist calculate and analysis.
The method have the benefit that:
1, the present invention is difficult to carry out the deficiency of symbolic operation during can making up previous Ansys secondary development.In science
In calculating, symbolic operation can obtain precise results, for common computational problem, such as solve micro-, integral, nonlinear equation
Group, differential equation group etc. can directly obtain analytic solutions using the powerful symbolic operation ability of Matlab, based on Fortran with
In the Ansys secondary development of Matlab shuffling environment, by calling Matlab Symbolic Toolbox that can effectively improve Ansys
Computational accuracy.
2, the present invention can promote the Visual Performance of Ansys secondary development.In finite element secondary development, user is often
Wonder that it calculates the situation of change of intermediate variable, due to the Ansys that is write based on Fortran language to graphics capability compared with
It is weak, in the Ansys secondary development based on Fortran and Matlab shuffling environment, calling Matlab powerful graphics process energy
Power easily can enable calculated result visualize.
3, the present invention greatly shortens Ansys secondary development by calling Matlab a large amount of mature functions and tool box
Period.If the method for writing common numerical solution differential equation group using Fortran language, such as Euler method, backward forward
Euler method, runge kutta method etc., then it is complex, since Matlab is integrated with function library abundant, based on Fortran with
In the Ansys secondary development of Matlab shuffling environment, these numerical methods can pass through Matlab several simple function languages
Sentence is realized, and need to only change a small number of program statements, so that it may different Numerical Methods Solves is selected, convenient between different numerical methods
It compares, the period of program development is greatly saved.
4, the present invention can be realized limited by the Optimization Toolbox for calling Matlab powerful by Ansys secondary development
Complicated optimization problem in first Parameter analysis.For multi-objective optimization question, Ansys included optimization module tends not to obtain
Good optimization solution, and Matlab has powerful Optimization Toolbox, in the Ansys based on Fortran Yu Matlab shuffling environment
In secondary development, the Optimization Toolbox of Matlab institute band can be called, to solve complicated optimization problem.
Detailed description of the invention
Fig. 1 is that the Ansys secondary development process based on Fortran and Matlab hybrid programming illustrates.
Fig. 2 is reinforcing bar crack surface diagram.
Fig. 3 is reinforcing bar tension analysis of fatigue finite element model diagram.
Fig. 4 is that reinforcing bar crack surface expands diagram.
Fig. 5 is that crack length a (mm) is illustrated with fatigue loading times N change curve.
Fig. 6 is that crack length b (mm) is illustrated with fatigue loading times N change curve.
Fig. 7 is that tired overall process stress-strain curve diagram shows.
Fig. 8 is that tired overall process strain is illustrated with fatigue loading times N change curve.
Fig. 9 is that reinforcing bar fatigue overstrain is illustrated with fatigue loading times N change curve.
Figure 10 is the fatigue damage variables D of reinforcing bar with the change curve of fatigue loading number.
Figure 11 is that reinforcing bar fatigue residual intensity is illustrated with fatigue loading times N change curve.
Specific embodiment
Below in conjunction with specific embodiment, referring to attached drawing, the invention will be further described:
Fig. 1 is the flow chart of the Ansys secondary development the present invention is based on Matlab Yu Fortran shuffling, including installation is soft
Part, the working environment for building Fortran and Ansys secondary development, configuration Matlab and Fortran hybrid programming working environment,
It is opened with Ansys creation finite element model, the interface for building Ansys secondary development, using Matlab and Fortran hybrid programming
Send out Ansys user's favorite subroutine, Ansys main program calls user's favorite subroutine to carry out subsequent finite element method (fem) analysis.
Embodiment: the secondary development of this structure of reinforcing bar fatigue damage, using UPFs to the fatigue damage constitutive relation of reinforcing bar into
The fatigue damage deterioration law of reinforcing bar is studied in row secondary development, estimates the fatigue life of reinforcing bar, and obtain under fatigue load
Mechanical property variation.
Classical Damage Constitutive Model is general in Continuum Mechanics are as follows:
σ=(1-D) E0ε
Wherein D be damage variable, for reinforcing bar analysis of fatigue, D be commonly defined as reinforcing bar damage face (crack surface) area with
Lossless area ratio, as shown in Figure 2, it is assumed that the crack surface of steel reinforcing bar specimen is surrounded by semiellipse and semi-circumference, then is had:
In formula: AcrFor crackle area;A0For the area under reinforcing bar nondestructive state.Crack surface area can be acquired by following formula:
Wherein fatigue crack length (a, b) can gradually be extended with the increase of fatigue loading frequency n, and propagation law can press
Paris formula is calculated:
In formula: Ca, Cb, m is test fitting coefficient;Δ σ is Fatigue Stress Amplitude;α is form factor, is one about a, b
Function.
By taking new 12 reinforcing bar of II Φ of 20MnSiV as an example, checking in the new II reinforcing bar fatigue upper limit of 20MnSiV is 354MPa, under tired
It is limited to 35MPa, yield strength 488MPa, ultimate tensile intensity is 640MPa and Ca=Cb=6.9, m=3 value and a experience
Calculating formula, using Fortran and Matlab shuffling technology, by the fatigue damage of reinforcing bar, this structure is written as user's according to the present invention
Program carries out secondary development, and referring to Fig.1, process is as follows:
1), following software is installed under Windows7 system: Ansys14.5, Fortran11.1,
Visualstudio2008, Matlab 2012b;
2) working environment of Fortran Yu Ansys secondary development, are built: being set first, be respectively Path,
Lib and include;Then will need the user's favorite subroutine that compiles copy to ANSYS Inc v145 ANSYS custom
User under intel file, then successively click beginning > all program > ANSYS14.5 > Utilities, click therein
ANS_ADMIN, then click Relink ANSYS therein and enter compiling interface, connection is finally compiled according to interface prompt,
Will appear after compiling successfully " prompt of LINK WAS SUCCESSFUL ".
3) it configures Matlab working environment: keying in order Mex under Matlab command prompt and be aided with parameter-f and phase
The source program name that the option file and needs answered compile, format are as follows: Mex-f<Matlab>bin
Optsfilename.bat filename.f, after environment configurations success, mex order is returned directly under Matlab command prompt.
4) reinforcing bar tension analysis of fatigue finite element model as shown in Figure 3 is established using LINK180 unit in Ansys,
User builds Ansys second development interface, and interface routine is as follows:
4) user's favorite subroutine is write, states Matlab interface (API) function, including Engine function and access function;
5) definition pointer variable, in the hybrid programming of Matlab and Fortran, pointer is the unique side for transmitting array
Formula;
6) start Matlab engine;
7) output matrix is created, the basic operation unit of Matlab is matrix, and the basic operation unit of Fortran is
Number, therefore the value that Fortran is passed in Matlab must be converted into matrix form;
8) Fortran array is transferred in Matlab output matrix;
9) by the working space of output matrix write-in Matlab;
10) the Matlab function needed for executing: by calling the INT function in Matlab symbolic math toolbox (to solve
Integral function) solve reinforcing bar crack surface area Acr, the kernel program for executing symbolic integration is as follows:
Call engEvalString(ep,’syms y x a b R’)
Call engEvalString (ep, ' y=sqrt (a^2- (a^2/b^2) * x^2-sqrt (R^2-x^2)-R) ')
Call engEvalString (ep, ' Acr=2*int (y, x, 0, b) ')
Call engEvalString (ep, ' a=subs (y, a, a0) ')
Call engEvalString (ep, ' B=subs (y, b, b0) ')
Call engEvalString (ep, ' R=subs (y, R, R0) ')
It calls the function of numerical value computing differential equation in Matlab to ask uncoupled differential equation group (Paris formula), holds
The core code of row numerical solution differential equation group is as follows:
Defined function file in %Matlab
Function dy=rigid (x, n);
Dy (1)=C* (F*stress*sqrt (pi*y (1))) ^m;
Dy (2)=C* (F*stress*sqrt (pi*y (2))) ^m;
Matlab function is called in %Fortran
C is with the 4/5 rank Runge-Kutta method combined
Call engEvalString (ep, ' [n, y]=ode45 (' rigid ', [t1t2], [a0b0]) ')
11) Matlab calculated result is returned into Fortran user's favorite subroutine,.
12) Ansys main program calls the calculated result of Fortran user's favorite subroutine, then carries out subsequent finite element analysis
It calculates.
Main calculation results are as shown in Fig. 4 to Figure 11.Fig. 4 is that reinforcing bar crack surface expands diagram;Fig. 5 is crack length a
(mm) it is illustrated with fatigue loading times N change curve;Fig. 6 is crack length b (mm) with fatigue loading times N change curve
Show;Fig. 7 is that tired overall process stress-strain curve diagram shows;Fig. 8 is that tired overall process strain is bent with the variation of fatigue loading times N
Line chart shows;Fig. 9 is that reinforcing bar fatigue overstrain is illustrated with fatigue loading times N change curve;Figure 10 is the fatigue damage of reinforcing bar
Variables D with fatigue loading number change curve;Figure 11 is reinforcing bar fatigue residual intensity with fatigue loading times N change curve
Diagram.
Claims (5)
1. a kind of Ansys Secondary based on Matlab Yu Fortran hybrid programming, it is characterised in that: Fortran with
Matlab shuffling carries out the step of Ansys secondary development, including installation corresponding software, configuration Fortran and Ansys secondary development
Working environment, configuration Matlab and Fortran hybrid programming working environment, with Ansys create finite element model, build
The interface of Ansys secondary development develops Ansys user's favorite subroutine, the main journey of Ansys using Matlab and Fortran hybrid programming
Sequence calls user's favorite subroutine to carry out subsequent finite element method (fem) analysis.
2. a kind of Ansys Secondary based on Matlab Yu Fortran hybrid programming according to claim 1,
It is characterized by: the installation corresponding software, it is contemplated that the compatibling problem between each software different editions, the present invention recommend each
Software installation version is Ansys14.5, Fortran11.1, Visualstudio2008, Matlab2012b.User can also basis
The Ansys version itself bought matched with reference to its user's favorite subroutine help document corresponding Fortran with
Visualstudio version.
3. a kind of Ansys Secondary based on Matlab Yu Fortran hybrid programming according to claim 1,
It is characterized by: the working environment of configuration Fortran and Ansys secondary development, need to compile, connect and activation UPFs (user
Programmable features);Three environmental variances are set first, are Path, Lib and include respectively;Then user needs compiled
Subprogram copy to ANSYS Inc v145 ANSYS custom user under intel file, then successively click beginning >
All program > ANSYS14.5 > Utilities, click ANS_ADMIN therein, then click Relink ANSYS therein and enter
Interface is compiled, connection is finally compiled according to interface prompt, will appear after compiling successfully " LINK WAS SUCCESSFUL "
Prompt.
4. a kind of Ansys Secondary based on Matlab Yu Fortran hybrid programming according to claim 1,
It is characterized by: configuration Matlab and Fortran hybrid programming working environment, key in order under Matlab command prompt
Mex is simultaneously aided with the source program name that parameter-f and corresponding option file and needs compile, and format is as follows: Mex-f <
Matlab > bin optsfilename.bat filename.f, if environment configurations succeed, mex order will not return appoint
What information, is returned directly under Matlab command prompt.
5. a kind of Ansys Secondary based on Matlab Yu Fortran hybrid programming according to claim 1,
It is characterized by: developing Ansys user's favorite subroutine using Matlab and Fortran hybrid programming, Matlab interface is stated first
(API) function, including Engine function and access function, definition pointer variable;Then start Matlab engine and create output square
Battle array, Fortran array is transferred in Matlab output matrix and the working space of Matlab is written, needed for finally executing
Calculated result is returned to Fortran user's favorite subroutine by Matlab program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710346108.XA CN109240659A (en) | 2017-05-17 | 2017-05-17 | A kind of Ansys Secondary based on Fortran Yu Matlab hybrid programming |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710346108.XA CN109240659A (en) | 2017-05-17 | 2017-05-17 | A kind of Ansys Secondary based on Fortran Yu Matlab hybrid programming |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109240659A true CN109240659A (en) | 2019-01-18 |
Family
ID=65082886
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710346108.XA Pending CN109240659A (en) | 2017-05-17 | 2017-05-17 | A kind of Ansys Secondary based on Fortran Yu Matlab hybrid programming |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109240659A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112650484A (en) * | 2020-12-29 | 2021-04-13 | 中国航发控制系统研究所 | Mixed programming modeling method based on Rhapmodel tool |
-
2017
- 2017-05-17 CN CN201710346108.XA patent/CN109240659A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112650484A (en) * | 2020-12-29 | 2021-04-13 | 中国航发控制系统研究所 | Mixed programming modeling method based on Rhapmodel tool |
CN112650484B (en) * | 2020-12-29 | 2022-03-04 | 中国航发控制系统研究所 | Mixed programming modeling method based on Rhapmodel tool |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Lubin et al. | Computing in operations research using Julia | |
Urban | MPTP–motivation, implementation, first experiments | |
Guerra et al. | System-level design guidance using algorithm properties | |
Jones et al. | Practical formal verification in microprocessor design | |
Jia et al. | Generating systolic array accelerators with reusable blocks | |
Turkiyyah et al. | Knowledge-based assistance for finite-element modeling | |
Mbongue et al. | Automatic generation of application-specific FPGA overlays with rapidwright | |
CN103176894A (en) | Test data automatic derivative method and automatic derivative device facing database | |
Goknil et al. | Tool support for generation and validation of traces between requirements and architecture | |
CN109240659A (en) | A kind of Ansys Secondary based on Fortran Yu Matlab hybrid programming | |
Li et al. | Efficient implementation of FPGA based on Vivado high level synthesis | |
Bracewell et al. | A methodology for computational design tool research | |
WO2024082530A1 (en) | High-performance virtual simulation method and system driven by digital twin data model | |
Saptawijaya et al. | Tabdual: a tabled abduction system for logic programs. | |
Le Digabel et al. | NOMAD user guide version 3.9. 1 | |
Heikkinen | Transparency of design automation systems using visual programming–within the mechanical manufacturing industry | |
Benkert et al. | MaterialModeler—From experimental raw data to a material model | |
Agliada et al. | On the reuse of VHDL modules into systemC designs | |
Crain | Simulation with GPSS/H | |
Lou et al. | Direct merging of triangle meshes preserving simulation semantics for fast modification of numerical models | |
Evans et al. | Existing Fortran interfaces to Trilinos in preparation for exascale ForTrilinos development | |
Meeraus et al. | GAMS | |
Russell et al. | From Tensor Algebra to Hardware Accelerators: Generating Streaming Architectures for Solving Partial Differential Equations | |
Belkhir et al. | Rewriting and symbolic transformations for multi-scale methods | |
Khoury et al. | Vector-Vector-Matrix Architecture: A Novel Hardware-Aware Framework for Low-Latency Inference in NLP Applications |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20190118 |
|
WD01 | Invention patent application deemed withdrawn after publication |