Skip to content

Commit bbaf1a3

Browse files
committed
Merge remote-tracking branch 'origin/zhanqun/prev5'
2 parents ea1fbe9 + fbdfdbc commit bbaf1a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+10966
-1292
lines changed
26.1 KB
Loading
27.7 KB
Loading
34.6 KB
Loading
34.6 KB
Loading

docker/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Pydyna-pre service Linux-based Dockerfile
2+
3+
FROM python:3.8-slim-buster
4+
5+
# Define the working directory
6+
WORKDIR /server
7+
8+
# Install unzip
9+
RUN apt-get update && apt-get install -y unzip
10+
11+
# Add the binary files from the latest release
12+
COPY linux-binaries.zip .
13+
RUN unzip -qu linux-binaries.zip && rm linux-binaries.zip
14+
15+
RUN pip3 install grpcio grpcio-tools protobuf
16+
17+
RUN python -m grpc_tools.protoc --python_out=./linux-binaries --grpc_python_out=./linux-binaries -I./linux-binaries ./linux-binaries/kwprocess.proto
18+
19+
CMD ["python3", "./linux-binaries/kwserver.py"]

docker/README.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Create your own pydyna-pre service docker container
2+
=================================================
3+
4+
The pydyna-pre service Docker containers can be easily built by following
5+
these steps.
6+
7+
Inside this folder, the instructions (i.e. ``Dockerfile.*`` files) for
8+
building the pydyna-pre service Docker containers are made available.
9+
10+
* ``Dockerfile``: this file builds the Linux-based Docker image.
11+
12+
Prerequisites
13+
^^^^^^^^^^^^^
14+
15+
* Ensure that ``docker`` is installed in your machine.
16+
If you do not have ``docker`` available, please refer to the
17+
`official Docker site <https://www.docker.com>`_.
18+
19+
* Download the latest release artifacts for the Linux
20+
Docker container. You can do this as follows:
21+
22+
* Latest Linux artifacts: `linux-binaries.zip <https://github.com/ansys/pydyna/releases/latest/download/linux-binaries.zip>`_
23+
24+
* Move these ``.zip`` files to the current location (i.e. ``<repository-root-folder>/docker``).
25+
26+
Building the Docker images
27+
^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
29+
In order to build your images, follow the next instructions:
30+
31+
* Locate yourself at ``<repository-root-folder>/docker`` in your terminal.
32+
* Run the following Docker command:
33+
34+
.. code:: bash
35+
36+
docker build -t ls-pre .
37+
38+
* Check that the image has been created successfully. You should see an output similar
39+
to this one when running the following command:
40+
41+
.. code:: bash
42+
43+
docker images
44+
45+
>>> REPOSITORY TAG IMAGE ID CREATED SIZE
46+
>>> ls-pre *******-latest ............ X seconds ago 187MB
47+
>>> ...... ...... ............ .............. ......

examples/EM/em_resistive_heating.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454

5555
matelastic1 = MatElastic(mass_density=8000, young_modulus=1e11, poisson_ratio=0.33)
5656
matelastic2 = MatElastic(mass_density=7000, young_modulus=1e11, poisson_ratio=0.33)
57-
matelastic1.set_electromagnetic_property(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=6e7)
58-
matelastic2.set_electromagnetic_property(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=4e6,eos=EMEOSTabulated1(Curve(x=[0, 25, 50, 100], y=[4e6, 4e6, 4e5, 4e5])))
57+
matelastic1.set_em_permeability_equal(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=6e7)
58+
matelastic2.set_em_permeability_equal(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=4e6,eos=EMEOSTabulated1(Curve(x=[0, 25, 50, 100], y=[4e6, 4e6, 4e5, 4e5])))
5959

6060
matthermaliso1 = MatThermalIsotropic(density=8000,specific_heat=400, conductivity=400)
6161
matthermaliso2 = MatThermalIsotropic(density=7000,specific_heat=450, conductivity=40)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"""
2+
Resistive heating 2D
3+
====================
4+
5+
This example features a simple metal bar where potential is imposed on both ends. \n
6+
LS-DYNA version : ls-dyna_smp_d_R13.1_138-g8429c8a10f_winx64_ifort190.exe
7+
"""
8+
9+
import os
10+
import sys
11+
12+
from ansys.dyna.core.pre.dynasolution import DynaSolution
13+
from ansys.dyna.core.pre.dynaem import (
14+
DynaEM,
15+
PartSet,
16+
NodeSet,
17+
Curve,
18+
ShellPart,
19+
ShellFormulation,
20+
FEMSOLVER,
21+
ThermalAnalysis,
22+
ThermalAnalysisType,
23+
EMType,
24+
Isopotential_ConnType,
25+
Isopotential
26+
)
27+
from ansys.dyna.core.pre.dynamaterial import MatRigid,MatThermalIsotropic,EMMATTYPE,EMEOSTabulated1
28+
from ansys.dyna.core.pre import examples
29+
# sphinx_gallery_thumbnail_path = '_static/pre/em/resistive_heating_2d.png'
30+
31+
hostname = "localhost"
32+
if len(sys.argv) > 1:
33+
hostname = sys.argv[1]
34+
35+
solution = DynaSolution(hostname)
36+
fns = []
37+
path = examples.em_resistive_heating_2d + os.sep
38+
fns.append(path + "em_resistive_heating_2d.k")
39+
solution.open_files(fns)
40+
solution.set_termination(termination_time=0.0101)
41+
solution.create_database_binary(dt=1e-4)
42+
43+
emobj = DynaEM()
44+
solution.add(emobj)
45+
46+
emobj.set_timestep(tssfac=1,timestep_size_for_mass_scaled=1e-4)
47+
48+
emobj.analysis.set_timestep(timestep=1e-4)
49+
emobj.analysis.set_em_solver(type=EMType.RESISTIVE_HEATING)
50+
emobj.analysis.set_solver_fem(solver=FEMSOLVER.DIRECT_SOLVER, relative_tol=1e-3)
51+
52+
tanalysis = ThermalAnalysis()
53+
tanalysis.set_timestep(initial_timestep=1e-4)
54+
tanalysis.set_solver(analysis_type=ThermalAnalysisType.TRANSIENT)
55+
emobj.add(tanalysis)
56+
57+
matrigid = MatRigid(mass_density=1, young_modulus=2e11)
58+
matrigid.set_em_resistive_heating_2d(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=1e4)
59+
60+
matthermaliso = MatThermalIsotropic(density=100,specific_heat=10, conductivity=7)
61+
62+
part = ShellPart(1)
63+
part.set_material(matrigid,matthermaliso)
64+
part.set_element_formulation(ShellFormulation.PLANE_STRESS)
65+
emobj.parts.add(part)
66+
67+
emobj.boundaryconditions.create_imposed_motion(PartSet([1]), Curve(x=[0,10],y=[10,10]))
68+
emobj.set_init_temperature(temp=25)
69+
emobj.connect_isopotential(contype = Isopotential_ConnType.VOLTAGE_SOURCE,isopotential1 = Isopotential(NodeSet([521,517,513,509,525])),value=500)
70+
emobj.connect_isopotential(contype = Isopotential_ConnType.VOLTAGE_SOURCE,isopotential1 = Isopotential(NodeSet([585,605,625,564,565])))
71+
72+
emobj.create_em_output(mats=2, matf=2, sols=2, solf=2)
73+
74+
solution.save_file()
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""
2+
Resistive heating 2D connect isopotential
3+
=========================================
4+
5+
This example shows how two parts can be simply connected with one another by using connect_isopotential(). \n
6+
LS-DYNA version : ls-dyna_smp_d_R13.1_138-g8429c8a10f_winx64_ifort190.exe
7+
"""
8+
9+
import os
10+
import sys
11+
12+
from ansys.dyna.core.pre.dynasolution import DynaSolution
13+
from ansys.dyna.core.pre.dynaem import (
14+
DynaEM,
15+
PartSet,
16+
NodeSet,
17+
SegmentSet,
18+
Curve,
19+
ShellPart,
20+
ShellFormulation,
21+
FEMSOLVER,
22+
ThermalAnalysis,
23+
ThermalAnalysisType,
24+
EMType,
25+
Isopotential_ConnType,
26+
Isopotential,
27+
RogoCoil,
28+
EMDimension
29+
)
30+
from ansys.dyna.core.pre.dynamaterial import MatRigid,MatThermalIsotropic,EMMATTYPE,EMEOSTabulated1
31+
from em_set_data import rogoseg
32+
from ansys.dyna.core.pre import examples
33+
# sphinx_gallery_thumbnail_path = '_static/pre/em/resistive_heating_2d_isopots.png'
34+
35+
hostname = "localhost"
36+
if len(sys.argv) > 1:
37+
hostname = sys.argv[1]
38+
39+
solution = DynaSolution(hostname)
40+
fns = []
41+
path = examples.em_resistive_heating_2d_isopots + os.sep
42+
fns.append(path + "em_resistive_heating_2d_isopots.k")
43+
solution.open_files(fns)
44+
solution.set_termination(termination_time=0.0101)
45+
solution.create_database_binary(dt=1e-4)
46+
47+
emobj = DynaEM()
48+
solution.add(emobj)
49+
50+
emobj.set_timestep(tssfac=1,timestep_size_for_mass_scaled=1e-4)
51+
52+
emobj.analysis.set_timestep(timestep=1e-4)
53+
emobj.analysis.set_em_solver(type=EMType.RESISTIVE_HEATING,dimtype=EMDimension.PLANAR_2D)
54+
emobj.analysis.set_solver_fem(solver=FEMSOLVER.DIRECT_SOLVER, relative_tol=1e-3)
55+
56+
tanalysis = ThermalAnalysis()
57+
tanalysis.set_timestep(initial_timestep=1e-4)
58+
tanalysis.set_solver(analysis_type=ThermalAnalysisType.TRANSIENT)
59+
emobj.add(tanalysis)
60+
61+
matrigid = MatRigid(mass_density=1, young_modulus=2e11)
62+
matrigid.set_em_resistive_heating_2d(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=1e4)
63+
64+
matthermaliso = MatThermalIsotropic(density=100,specific_heat=10, conductivity=7)
65+
66+
part = ShellPart(1)
67+
part.set_material(matrigid,matthermaliso)
68+
part.set_element_formulation(ShellFormulation.PLANE_STRESS)
69+
emobj.parts.add(part)
70+
71+
emobj.boundaryconditions.create_imposed_motion(PartSet([1]), Curve(x=[0,10],y=[10,10]))
72+
emobj.set_init_temperature(temp=25)
73+
74+
emobj.connect_isopotential(contype = Isopotential_ConnType.VOLTAGE_SOURCE,isopotential1 = Isopotential(NodeSet([521,517,513,509,525])),value=500)
75+
emobj.connect_isopotential(contype = Isopotential_ConnType.SHORT_CIRCUIT,isopotential1 = Isopotential(NodeSet([642,652,661,670,643])),isopotential2 = Isopotential(NodeSet([549,548,577,597,617])),value=0.01)
76+
emobj.connect_isopotential(contype = Isopotential_ConnType.VOLTAGE_SOURCE,isopotential1 = Isopotential(NodeSet([653,644,626,627,662])))
77+
emobj.add(RogoCoil(SegmentSet(rogoseg)))
78+
79+
emobj.create_em_output(mats=2, matf=2, sols=2, solf=2)
80+
81+
solution.save_file()
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""
2+
Resistive heating 2D multiple connect isopotential
3+
==================================================
4+
5+
This example aims to further drive the point that complex circuits can be defined as inlet boundary conditions. \n
6+
LS-DYNA version : ls-dyna_smp_d_R13.1_138-g8429c8a10f_winx64_ifort190.exe
7+
"""
8+
9+
import os
10+
import sys
11+
12+
from ansys.dyna.core.pre.dynasolution import DynaSolution
13+
from ansys.dyna.core.pre.dynaem import (
14+
DynaEM,
15+
PartSet,
16+
NodeSet,
17+
SegmentSet,
18+
Curve,
19+
ShellPart,
20+
ShellFormulation,
21+
FEMSOLVER,
22+
ThermalAnalysis,
23+
ThermalAnalysisType,
24+
EMType,
25+
Isopotential_ConnType,
26+
Isopotential,
27+
RogoCoil,
28+
EMDimension
29+
)
30+
from ansys.dyna.core.pre.dynamaterial import MatRigid,MatThermalIsotropic,EMMATTYPE
31+
from em_set_data import rogoseg
32+
from ansys.dyna.core.pre import examples
33+
# sphinx_gallery_thumbnail_path = '_static/pre/em/resistive_heating_2d_isopots.png'
34+
35+
hostname = "localhost"
36+
if len(sys.argv) > 1:
37+
hostname = sys.argv[1]
38+
39+
solution = DynaSolution(hostname)
40+
fns = []
41+
path = examples.em_resistive_heating_2d_multi_isopots + os.sep
42+
fns.append(path + "em_resistive_heating_2d_multi_isopots.k")
43+
solution.open_files(fns)
44+
solution.set_termination(termination_time=0.0101)
45+
solution.create_database_binary(dt=1e-4)
46+
47+
emobj = DynaEM()
48+
solution.add(emobj)
49+
50+
emobj.set_timestep(tssfac=1,timestep_size_for_mass_scaled=1e-4)
51+
52+
emobj.analysis.set_timestep(timestep=1e-4)
53+
emobj.analysis.set_em_solver(type=EMType.RESISTIVE_HEATING,dimtype=EMDimension.PLANAR_2D)
54+
55+
tanalysis = ThermalAnalysis()
56+
tanalysis.set_timestep(initial_timestep=1e-4)
57+
tanalysis.set_solver(analysis_type=ThermalAnalysisType.TRANSIENT)
58+
emobj.add(tanalysis)
59+
60+
matrigid = MatRigid(mass_density=1, young_modulus=2e11)
61+
matrigid.set_em_resistive_heating_2d(material_type=EMMATTYPE.CONDUCTOR, initial_conductivity=1e4)
62+
63+
matthermaliso = MatThermalIsotropic(density=100,specific_heat=10, conductivity=7)
64+
65+
part = ShellPart(1)
66+
part.set_material(matrigid,matthermaliso)
67+
part.set_element_formulation(ShellFormulation.PLANE_STRESS)
68+
emobj.parts.add(part)
69+
70+
emobj.boundaryconditions.create_imposed_motion(PartSet([1]), Curve(x=[0,10],y=[10,10]))
71+
emobj.set_init_temperature(temp=25)
72+
73+
crv = Curve(func="-5./0.01*EXP(-TIME/((5.e-4+0.05+0.01)*0.04))")
74+
nset1 = NodeSet([521,517,513,509,525])
75+
nset2 = NodeSet([549,548,577,597,617])
76+
nset3 = NodeSet([653,644,626,627,662])
77+
nset4 = NodeSet([642,652,661,670,643])
78+
emobj.connect_isopotential(contype = Isopotential_ConnType.CURRENT_SOURCE,isopotential1 = Isopotential(nset4),isopotential2 = Isopotential(nset2),curve=crv)
79+
emobj.connect_isopotential(contype = Isopotential_ConnType.RESISTANCE,isopotential1 = Isopotential(nset4),isopotential2 = Isopotential(nset2),value=0.01)
80+
emobj.connect_isopotential(contype = Isopotential_ConnType.RESISTANCE,isopotential1 = Isopotential(nset3),isopotential2 = Isopotential(nset1),value=0.05)
81+
emobj.add(RogoCoil(SegmentSet(rogoseg)))
82+
83+
emobj.create_em_output(mats=2, matf=2, sols=2, solf=2)
84+
85+
solution.save_file()

0 commit comments

Comments
 (0)