Abaqus: parametric geometry/assembly in Inputfile or Python script? - python

i want to do something as a parametric study in Abaqus, where the parameter i am changing is a part of the assembly/geometry.
Imagine the following:
A cube is hanging on 8 ropes. Each two of the 8 ropes line up in one corner of a room. the other ends of the ropes merge with the room diagonal of the cube. It's something like a cable-driven parallel robot/rope robot.
Now, i want to calculate the forces in the ropes in different positions of the cube, while only 7 of the 8 ropes are actually used. That means i have 8 simulations for each position of my cube.
I wrote a matlab script to generate the nodes and wires of the cube in different positions and angle of rotations so i can copy them into an input file for Abaqus.
Since I'm new to Abaqus scripting etc, i wonder which is the best way to make this work.
would you guys generate 8 input files for one position of the cube and calculate
them manually or is there a way to let abaqus somehow iterate different assemblys?
I guess i should wright a python script, but i don't know how to make the ropes the parameter that is changing.
Any help is appreciated!
Thanks, Tobi

In case someon is interested, i was able to do it the following way:
I created a model in abaqus till the point, i could have started the job. Then i took the .jnl file (which is created automaticaly by abaqus) and saved it as a .py file. Then i modified this script by defining every single point as a variable and every wire for the parts as tuples, consisting out of the variables. Than i made for loops and for every 9 cases unique wire definitions, which i called during the loop. During the loop also the constraints were changed and the job were started. I also made a field output request for the endnodes of the ropes (representing motors) for there coordinates and reaction force (the same nodes are the bc pinned)
Then i saved the fieldoutput in a certain simple txt file which i was able to analyse via matlab.
Then i wrote a matlab script which created the points, attached them to the python script, copied it to a unique directory and even started the job.
This way, i was able to do geometric parametric studies in abaqus using matlab and python.
Code will be uploaded soon

Related

Storing Procedurally Generated Map Data Inside a NumPy Array

So, I am making a roguelike game using Python as my language. I am using NumPy and tcod currently for libraries, and I have been trying to figure out how I can take the procedurally generated map "cells," and append them to indexes within a NumPy array.
Context: I have followed the 2020 tcod tutorial found on the roguelikedev subreddit to get to the point I am at now (Here is a link to the source on GitHub. I have made only trivial changes to colors and such so far). I've coded simple stuff in Java before but never messed with Python much, nor have I ever tried something like this. In short, I feel a little lost.
Basically, I want to change the way the maps are generated. Currently, an area the size of the terminal is preocedurally generated, and when the player moves down some stairs, a new map is generated, and the old one is basically thrown away. The idea being that it's a dungeon. I don't want this. My goal is to have it be an open map, where the player can go North, South, East, or West.
This would require the engine to save the map (I assume to a list or an array or something), and keep updating it whenever the player moves to a new cell on the grid.
Now I'm not asking anyone to write the code for me, but I just can't seem to really wrap my head around how to go about actually doing this.
So far, my problem is I don't know exactly how to put the gamemaps onto a list. Should I make them entries within a dictionary? Use a list? Is what I'm trying to do even possible?
Figured I'd give this site a shot. Any help is appreciated.

Recognition and recording of digits from external window in real time using python

I want to gather numbers that are being output from a specific window in real time as data points.
I have a piece of equipment with an internal pressure level I would like to monitor. The only output that the software I'm using gives me is a single float from the last ~second in a box within the software. I've asked the manufacturers if there was any way of internal accessing this output and they basically told me there is none.
Individual measurements don't mean much to me, and I'd like to see the change in pressure across time. But watching this single value all day isn't very practical for me. So I want to make something that can read a specific line of text by recognizing the words or by giving exact coordinates on the screen (either works), say 'Output PSI: ##.###' and get the ##.### in python as a data point every time the number changes.
Are there modules that anyone has experience with that might be of use here?

Abaqus Surface getSequenceFromMask

I am writing script in Abaqus, where I crush circle and square with cut circle (like cheese). I need to put Contact between parts so I need Surface.
macro manager generates:
s1 = a.instances['kolo-1'].edges
side1Edges1 = s1.getSequenceFromMask(mask=('[#1 ]', ), )
a.Surface(side1Edges=side1Edges1 , name='kolkoSurf')
The problem is: getSequenceFromMask(mask=('[#1 ]', ), )
How to get this #1? Can I replace it? I searched little and there were some ideas to use: 'find', 'face', 'COORDS' but I cannot manage it.
Please help me. I dream to get an simple example how to extract this Surface using X, Y or anyway.
BR,
Wonman
You recorded the above journal using the macro manager with default journal options. Therefore, the variable side1Edges1 is defined in your journal using the getSequenceFromMask()-method. This method is the recording of the selection you performed by clicking the GUI during the recording. This means you clicked the GUI to select an edge and the result is the getSequenceFromMask()-method acting on s1 which is a set of all edges of the instance 'kolo-1'.
According to Abaqus Scripting Reference Guide 6.14 - 7.2.2 the method getSequenceFromMask() is highly efficient when a large number of objects are involved. However, this is not very helpful if your trying to customize your journal file to select another geometry element to work with. There are two solutions:
Solution: Paste the command
session.journalOptions.setValues(replayGeometry=COORDINATE, recoverGeometry=COORDINATE)
into the Abaqus command line at the bottom of Abaqus CAE to set the members replayGeometry and recoverGeometry of your JournalOptions object to COORDINATE and repeat the recording of your journal.
You can, most of the time, omit clicking the GUI again by executing your old journal after issuing the command above.
You can then save your project, preferably with a new name, and use the newly created journal.
In the new journal the command getSequenceFromMask(mask=('[#1 ]', ), ) will by replaced by a selection based on coordinates to represent your recorded GUI-click.
You can then modify the coordinates in order to customize your journal file and to select the edge you like to use in subsequent modeling steps.
Solution: Define side1Edges1 using variables you defined from Scratch in the preceding lines of your python script. I recommend using the journal file as a blueprint in which all click-events have to be replaced using well known variables, defined by yourself. For example, define a list of points myPoints = [(0,0), (0,1) ] using your own logic and then use these points as arguments of the methods e.g. myLine = mySketch.Line(point1=myPoints[0], point2=myPoints[1]), constructing new variables like myLine for the usage in subsequent modeling steps.
To get a basic understanding of the modeling workflow using the Abaqus Python API, i can recommend
Puri, G. M., 2011. Python scripts for Abaqus : learn by example, 1st Edition, also it is hardly available in most universities.
Looking at the Abaqus Benchmark Guide can be helpful, as some newer Benchmarks contain Python scripts (e.g. Fracture Mechanics).
I suppose you are creating an edge based surface. There are many ways to do it, easiest one is
Create an assembly based set ("setName") of those edges for which you want to create surface.
instance=mdb.rootAssembly.instances["InstanceName"]
set_for_surface=instance.sets["setName"].edges
assembly.Surface(side1Edges=set_for_surface, name="surf_name")
Have look at findAt() or selecting region by bounding box "getBoundingBox()". See this SO answer, which is somewhat similar.
Edit: If the set is an assembly based set, access it directly from assembly not instance. Then, use the same procedure.
mdb.rootAssembly.sets['Set_name'].edges
Late to answer but i found simpler way to select all the edges by giving coordinates:
p = mdb.models['Model-1'].parts['Part-1']
e = p.edges
edges = e.getByBoundingBox(x1,y1,z1,x2,y2,z2)
p.Set(edges=edges, name='AllPartSet')
x, y and z are two coordinates for making a box.

How to get started with using Python for animal tracking?

I am using Python 3.X on macOS Sierra, and want to write a Python programme that should be able to: (1) load a 1 min video (format probably .avi), (2) identify white larvae (I am a biologist working on fly larvae) on a dark-ish background, (3) track the flies over the 1 min, and (4) output a .csv file with x- and y-coordinates for each larvae.
Now, what I am asking is not for anyone to write the code, I want to do that myself; rather, since I am totally new to working with videos, and only have marginal Python experience, it would help me for people to suggest a strategy I could follow to write that programme, such as specific modules that contain functions useful for this task, etc.

Abaqus: script to select elements on a surface

I am trying write an Abaqus/Python script that will select all the elements that "belong" to a certain face. I.e. taking all the elements that have a connection to one face of a meshed cube (I will calculate the total force acting on that face for force-displacement or stress-strain curves later).
If I do it using the GUI I get:
mdb.models['Model-1'].rootAssembly.Set(elements=
mdb.models['Model-1'].rootAssembly.instances['Part-1-1'].elements.getSequenceFromMask(
mask=('[#0:5 #fff80000 #ff #f #ffe00000 #f000000f #3f',
' #0:6 #fffe #c0003f00 #3 #3fff8 #ffc00 ]', ), ), name='Set-1')
But, getSequenceFromMask does not work in a general case. I tried using findat with no luck.
Is there a way to do that?
define a face set on the part or assembly:
part.Set('facename',faces=part.faces.findAt(((1,0,0),),))
where (1,0,0) is a coordinate anywhere on the face. (Don't use a point on a edge/corner though)
then after meshing you can access the elements attached to that face, something like:
instance.sets['facename'].elements
note if you want to get those elements on the odb after running an analysis it is a little different:
instance.elementSets['FACENAME'].elements
note that the set name is upcased on the odb..
One can select an specific element from its label by using:
mdb.models['model-name'].parts['part_name'].elements.getFromLabel(lable=element_id)
This way it is not necessary to have information about the coordinate of the element. Only the element id is enough to access to it.
You are apparently using a Macro in order to get the location of your surface in order to pick the set using Python. The issue is: the Macro facility uses getSequenceFromMask() by default and isn't very user-friendly...
Fortunately, this default option can be changed! One just needs to run the following line of code:
session.journalOptions.setValues(replayGeometry=COORDINATE,recoverGeometry=COORDINATE)
Now when you record a macro using the MacroManager, you get findAt() which is what you want.
Extra TIP:
You can include this piece of code in the onCaeStartup() function in your custom_v6.env file. It will then run every time you open CAE.
C:\Program Files\Dassault Systemes\SimulationServices\V6R2018x\win_b64\SMA\site\custom_v6.env
I had this issue myself a few days ago. Maybe I'm wrong but as far as I know, there is no way to directly select particular elements. You can select them with a "Bounding Box" or a "Bounding Sphere" or you can get them by your parts/ instances faces and cells. If you need to select the elements in a more specific way then you can get them by the nodes with which they are connected. You can use the "findAt" command with these nodes and get the elements by the "getElements()" command.
That is how I solved it and it works pretty fine. If there are other ways to solve that I will be happy to hear them because this is sometimes really frustrating.
Cheers

Categories

Resources