Code Monkey home page Code Monkey logo

pyfem's People

Contributors

jjcremmers avatar rozenlicht avatar soraros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyfem's Issues

Unable to use co_getpointvalues()

Hello, I am facing a problem when I call co_getpointvalues().

My full code is

import numpy as np
import time
import femm
import pyvista as pv 
import vtk

femm.openfemm()
# New magnetics problem
femm.newdocument(0)
femm.mi_probdef(20e3, 'centimeters', 'planar', 1e-8, 1, 30, 0)


def add_wire(center_pos, radius) -> None:
    x1 = center_pos[0] - radius / 2
    x2 = center_pos[0] + radius / 2
    y1 = center_pos[1]
    y2 = center_pos[1]

    femm.mi_drawarc(x1,y1,x2,y2,180,1)
    femm.mi_drawarc(x2,y2,x1,y1,180,1)

    # Add block labels at the center of each cable.
    femm.mi_addblocklabel(center_pos[0], center_pos[1])

    # Add/tag the materials to the blocks.
    femm.mi_selectlabel(center_pos[0], center_pos[1])
    femm.mi_setblockprop("Copper", 1, 0, "wires", 0, 1, 1)
    femm.mi_clearselected()

    # Add/tag the materials to the blocks.
    femm.mi_selectlabel(center_pos[0], center_pos[1])
    femm.mi_setblockprop("Copper", 1, 0, "wires", 0, 1, 1)
    femm.mi_clearselected()

# Cable 1 region.
x1 = 0.0
y1 = 0.0
x2 = 0.19
y2 = 0.0015
radius = np.sqrt((y2-y1)**2+(x2-x1)**2) / 2
cable1_x_midpoint = (x2+x1)/2
cable1_y_midpoint = (y2+y1)/2
wire_1 = add_wire((cable1_x_midpoint, cable1_y_midpoint), radius)

# Cable 2 region.
x3 = x1 + 0.2
y3 = y1 + 0.03
x4 = x2 + 0.3
y4 = y2 + 0.035

radius_2 = np.sqrt((y4-y3)**2+(x4-x3)**2) / 2
cable2_x_midpoint = (x4+x3)/2
cable2_y_midpoint = (y4+y3)/2
wire_2 = add_wire(((x4+x3)/2, (y4+y3)/2 ), radius_2)

# Add materials library.
femm.mi_addmaterial('Air')
femm.mi_addmaterial("Copper", 1, 1, 0, 0, 58)

# Add block label(s) in the surrounding air.
air_x_point = 2 * (x1 + x2 + x3 + x4)
air_y_point = 2 * (y1 + y2 + y3 + y4)
femm.mi_addblocklabel(air_x_point, air_y_point)

# Add the circuit, specifying the current in A and whether it is in parallel or series.
femm.mi_addcircprop("wires", 10, 1)

# Add/tag the materials to the blocks.
femm.mi_selectlabel(air_x_point, air_y_point)
femm.mi_setblockprop("Air", 1, 0, "<None>", 0, 0, 0)
femm.mi_clearselected()

# Boundary conditions.
femm.mi_makeABC()

# Display the generated geometry.
femm.mi_zoomnatural()

# Save the problem before analyzing.
femm.mi_saveas('automated_cable_proximity_losses.fem')

# Now,analyze the problem and load the solution when the analysis is finished
femm.mi_analyze()

femm.mi_loadsolution()

# Postprocessing.
current_density_center_0 = femm.mo_getj(cable2_x_midpoint,cable2_y_midpoint)
print(current_density_center_0)

Jx_center_0 = femm.co_getpointvalues(cable2_x_midpoint,cable2_y_midpoint)
Jy_center_0 = femm.co_getpointvalues(cable2_x_midpoint,cable2_y_midpoint)
print(current_density_center_0)
print(Jx_center_0)
print(Jy_center_0)
femm.closefemm()

And I get the error/traceback message:

Traceback (most recent call last):
  File "C:\file.py", line 128, in <module>
    Jx_center_0 = femm.co_getpointvalues(cable2_x_midpoint,cable2_y_midpoint)
  File "C:\Python3.10\lib\site-packages\femm\__init__.py", line 542, in co_getpointvalues
    return callfemm('co_getpointvalues(' + numc(x) + num(y) + ')' );
  File "C:\Python3.10\lib\site-packages\femm\__init__.py", line 156, in callfemm
    raise Exception(ErrorMsg)
Exception: error: attempt to call global `co_getpointvalues' (a nil value)
stack traceback:
   1:  main of string "lua2matlab(co_getpointvalues(0.345 0.03325)..." at line 1

The physical problem is successfully solved though, because I am able to retrieve the current density: (4.7261221179732225-3.277640943875099j). I don't know why I cannot access to any value returned by co_getpointvalues().
Any idea what I do wrong?

Adding Cam-Clay Plasticity to the material Models

Are there any plans to implement Mohr-Coulomb and Cam-Clay Plasticity models in PyFEM? In my opinion, it would be pretty instructive to see some commonly used constitutive models implemented in code.
Thank you.

Bug in the phase-field degradation function

A small bug is observed in the implementation of the Phase-field Element w.r.t., the degradation function (factor). In the code, factor = 1.0-phase*phase+self.k. Lines L86, L149. However, for AT1/AT2 phase-field fracture models, the degradation function needs to be, factor = pow(1.0-phase,2)+self.k.

Bug in the NewtonRaphson NonLinear algorithm (Update of element cordinates)

Hi,
First of all thank you for the code and nice work. It really helped me a lot to understand about the Nonlinear elements development.

I tried your example in the NR Nonlinear case and it is converging. However, when I checked the Jacobian matrix after each iteration it remains same where it should not be. Then, I investigated a bit and I saw that the element coordinates are not updated after each iteration. Only the element state is updated which is used for the deformation gradient. So, I think we need to update the element coordinates in order to have the right jacobian matrix and thus the right derivatives of shape functions after each iterations.

Please let me know if I am right or not and if yes, may be I can contribute to improve the code?if not, I am sorry about the inconvenience that caused you and please tell me where I was wrong.

Br,
Sijo George

mo_numnodes doesn't seem to work

I have a PyFEMM script that works, i.e. I can set up a whole problem and solve it, it returns numbers, etc.
I can visually see that a mesh is generated, however I would like to save it for further inspection.
Hence, I use mo_numnodes() with the hopes to retrieve the number of nodes. But this doesn't work.
This produces the error:

Traceback (most recent call last):
  File "test.py", line 84, in <module>
    num_nodes = femm.mo_numnodes()
  File "C:\Python3.10\lib\site-packages\femm\__init__.py", line 2002, in mo_numnodes
    return callfemm('mo_numnodes()');
  File "C:\Python3.10\lib\site-packages\femm\__init__.py", line 156, in callfemm
    raise Exception(ErrorMsg)
Exception: error: attempt to call global `mo_numnodes' (a nil value)
stack traceback:
   1:  main of string "lua2matlab(mo_numnodes())" at line 1

Anyone else having this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.