Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linear elastic example #167

Open
koubaa opened this issue Jan 31, 2024 · 2 comments
Open

Add linear elastic example #167

koubaa opened this issue Jan 31, 2024 · 2 comments

Comments

@koubaa
Copy link
Contributor

koubaa commented Jan 31, 2024

I use code like this elsewhere (I didn't test that this works, but it should at least be very close)

from ansys.materials.manager._models import Constant 
from ansys.materials.manager.material import Material
from ansys.materials.manager.util.matml.matml_from_material import MatmlWriter

e = 1e11 #young's modulus
p = 0.44 #possion's ratio
material = Material("MaterialName", material_id=1)
material.models.append(Constant("young's modulus x direction", e))
material.models.append(Constant("young's modulus y direction", e))
material.models.append(Constant("young's modulus z direction", e))
material.models.append(Constant("poisson's ratio xy", p))
material.models.append(Constant("poisson's ratio yz", p))
material.models.append(Constant("poisson's ratio xz", p))
matml_writer = MatmlWriter([material])
with open("matml.xml", "w") as f:
    matml_writer.write(f)
@koubaa
Copy link
Contributor Author

koubaa commented Jan 31, 2024

@rajesh1359 FYI

@rs-bh-n
Copy link

rs-bh-n commented Feb 1, 2024

Thanks Mohamed, this worked with these changes :


e = 2.3e11 #young's modulus
p = 0.4 #possion's ratio
s = 9.0e9
material = Material("Copper5", material_id=1)
material.models.append(Constant("young's modulus x direction", e))
material.models.append(Constant("young's modulus y direction", e))
material.models.append(Constant("young's modulus z direction", e))
material.models.append(Constant("poisson's ratio xy", p))
material.models.append(Constant("poisson's ratio yz", p))
material.models.append(Constant("poisson's ratio xz", p))
material.models.append(Constant("Shear Modulus XY", s))
material.models.append(Constant("Shear Modulus XZ", s))
material.models.append(Constant("Shear Modulus YZ", s))
matml_writer = MatmlWriter([material])
filepath = r"D:\S\matml5.xml"
matml_writer.export(filepath)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants