NumOpt 0.0.1__tar.gz → 0.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,33 @@
1
+ import re
2
+ from pathlib import Path
3
+ from ..cprint import cprint_green
4
+
5
+
6
+ def deal_name(nasfile, outfile, simplify=True):
7
+ def sub_func(match):
8
+ old_str: list = match.group().split("\n")
9
+ pshell_name = match.group("name")
10
+ if simplify:
11
+ pshell_name = pshell_name.split(":")[0]
12
+ pshell_id = match.group("id")
13
+ insert_str = f"$ANSA_NAME_COMMENT;{pshell_id};PSHELL;{pshell_name};"
14
+ old_str.insert(1, insert_str)
15
+ new_str = "\n".join(old_str)
16
+ return new_str
17
+
18
+ pattern = r"\$\*\s+Property:\s(?P<name>.*)\nPSHELL\s+(?P<id>\d+)\s+.*\n"
19
+ pattern = re.compile(pattern)
20
+
21
+ content = Path(nasfile).read_text()
22
+ new_content = re.sub(pattern, sub_func, content)
23
+ outfile = Path(outfile)
24
+ if not outfile.parent.exists():
25
+ outfile.parent.mkdir(exist_ok=True)
26
+ outfile.write_text(new_content)
27
+ cprint_green(f"new nastran file `{outfile.as_posix()}` is generated.")
28
+
29
+
30
+
31
+ if __name__ == "__main__":
32
+ nasfile = "./bulk.dat"
33
+ deal_name(nasfile, "new_bulk.dat")
@@ -0,0 +1,4 @@
1
+ from NumOpt.opti import *
2
+ from NumOpt.cprint import *
3
+
4
+ __version__ = "0.0.3"
@@ -0,0 +1,9 @@
1
+ from termcolor import cprint
2
+ from functools import partial
3
+
4
+
5
+ cprint_green = partial(cprint, color="green", attrs=["bold"])
6
+ cprint_magenta = partial(cprint, color="magenta", attrs=["bold"])
7
+ cprint_blue = partial(cprint, color="blue", attrs=["bold"])
8
+ cprint_red = partial(cprint, color="red", attrs=["bold"])
9
+ cprint_yellow = partial(cprint, color="yellow", attrs=["bold"])
File without changes
@@ -0,0 +1,89 @@
1
+ import NXOpen
2
+ import NXOpen.Features
3
+ from NXOpen import ParasolidExporter
4
+
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def create_af(coords, session: NXOpen.Session):
11
+ part = session.Parts.Work
12
+
13
+ markid = session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "create airfoil")
14
+ splineEX = part.Features.CreateStudioSplineBuilderEx(NXOpen.NXObject.Null)
15
+ for i in coords:
16
+ pt = NXOpen.Point3d(i[0] * 1000.0, i[1] * 1000.0, 0.0)
17
+ pt = part.Points.CreatePoint(pt)
18
+ gcons = splineEX.ConstraintManager.CreateGeometricConstraintData()
19
+ gcons.Point = pt
20
+ splineEX.ConstraintManager.Append(gcons)
21
+ spline = splineEX.Commit()
22
+ splineEX.Destroy()
23
+ session.UpdateManager.DoUpdate(markid)
24
+
25
+
26
+ def modify_af(coords, name, session: NXOpen.Session):
27
+ part = session.Parts.Work
28
+
29
+ markid = session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "modify airfoil")
30
+ spline = part.Features.FindObject(name)
31
+ splineEX = part.Features.CreateStudioSplineBuilderEx(spline)
32
+ for i, vi in enumerate(coords):
33
+ gcons = splineEX.ConstraintManager.FindItem(i)
34
+ pt = gcons.Point
35
+ pt.SetCoordinates(NXOpen.Point3d(vi[0] * 1000.0, vi[1] * 1000.0, 0.0))
36
+ splineEX.Evaluate()
37
+ spline = splineEX.Commit()
38
+ splineEX.Destroy()
39
+ session.UpdateManager.DoUpdate(markid)
40
+
41
+
42
+ def modify_expr(expr_name: str, value: float, session: NXOpen.Session, unit: str = None, update: bool = False):
43
+ markid = session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, f"modify {expr_name}")
44
+ part = session.Parts.Work
45
+ expr = part.Expressions.FindObject(expr_name)
46
+ unit = NXOpen.Unit.Null if unit is None else part.UnitCollection.FindObject(unit)
47
+ part.Expressions.EditExpressionWithUnits(expr, unit, f"{value:.6f}")
48
+ if update:
49
+ session.UpdateManager.DoUpdate(markid)
50
+
51
+
52
+ def export_solid(solid_name: list[str], outfile: str, session: NXOpen.Session):
53
+ markid = session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "export parasoild")
54
+
55
+ part = session.Parts.Work
56
+ parasolidExporter: ParasolidExporter = session.DexManager.CreateParasolidExporter()
57
+ parasolidExporter.InputFile = part.FullPath
58
+ parasolidExporter.OutputFile = outfile
59
+
60
+ parasolidExporter.ExportSelectionBlock.SelectionScope = NXOpen.ObjectSelector.Scope.SelectedObjects
61
+ for i in solid_name:
62
+ solid = part.Bodies.FindObject(i)
63
+ parasolidExporter.ExportSelectionBlock.SelectionComp.Add(solid)
64
+ parasolidExporter.Commit()
65
+ session.UpdateManager.DoUpdate(markid)
66
+
67
+
68
+ def saveAs(outfile, session: NXOpen.Session, overwrite: False):
69
+ outfile = Path(outfile)
70
+ if overwrite:
71
+ if outfile.exists():
72
+ os.unlink(outfile)
73
+ else:
74
+ if outfile.exists():
75
+ raise (f"{outfile} has been existed.")
76
+
77
+ markid = session.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, f"save as")
78
+ part = session.Parts.Work
79
+ part.SaveAs(outfile.as_posix())
80
+ session.UpdateManager.DoUpdate(markid)
81
+
82
+
83
+ if __name__ == "__main__":
84
+ with open("C:/Users/Zcaic/Desktop/hxy_ppt/coords.json", "r") as fin:
85
+ data = json.load(fin)
86
+
87
+ session = NXOpen.Session.GetSession()
88
+ # create_af(data["init_coords"],session=session)
89
+ modify_af(coords=data["init_coords"], name="SPLINE(1)", session=session)
@@ -1,16 +1,8 @@
1
1
  import aerosandbox.numpy as anp
2
2
  import aerosandbox as asb
3
3
  import casadi as cas
4
- from termcolor import cprint
5
- from functools import partial
6
4
  from typing import Callable, Any, Dict
7
-
8
- cprint_green = partial(cprint, color="green", attrs=["bold"])
9
- cprint_magenta = partial(cprint, color="magenta", attrs=["bold"])
10
- cprint_blue = partial(cprint, color="blue", attrs=["bold"])
11
- cprint_red = partial(cprint, color="red", attrs=["bold"])
12
- cprint_yellow = partial(cprint, color="yellow", attrs=["bold"])
13
-
5
+ from .cprint import cprint_yellow
14
6
 
15
7
  # def trape(y, x):
16
8
  # y = anp.array(y)
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: NumOpt
3
+ Version: 0.0.3
4
+ Summary: pti is a Python package that helps you design and optimize engineered systems.
5
+ Home-page: https://github.com/Zcaic/NumOpt.git
6
+ Author: Zcaic
7
+ License: MIT License
8
+
9
+ Copyright (c) 2019-2023 Peter Sharpe
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Project-URL: homepage, https://github.com/Zcaic/NumOpt.git
29
+ Keywords: optimization,automatic,differentiation
30
+ Classifier: Development Status :: 5 - Production/Stable
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: Topic :: Scientific/Engineering :: Physics
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3
35
+ Requires-Python: >=3.9
36
+ Description-Content-Type: text/markdown
37
+ License-File: LICENSE.txt
38
+ Requires-Dist: aerosandbox>=4.2.8
39
+ Requires-Dist: termcolor>=3.1.0
40
+ Dynamic: home-page
41
+ Dynamic: license-file
42
+ Dynamic: requires-python
43
+
44
+ **NumOpt is a Numerical Optimization Tool Python package that helps you design and optimize engineered systems.**
45
+
46
+ ```
47
+ pip install NumOpt
48
+ ```
@@ -1,10 +1,16 @@
1
1
  LICENSE.txt
2
2
  README.md
3
+ pyproject.toml
3
4
  setup.py
4
5
  NumOpt/__init__.py
6
+ NumOpt/cprint.py
5
7
  NumOpt/opti.py
6
8
  NumOpt.egg-info/PKG-INFO
7
9
  NumOpt.egg-info/SOURCES.txt
8
10
  NumOpt.egg-info/dependency_links.txt
9
11
  NumOpt.egg-info/requires.txt
10
- NumOpt.egg-info/top_level.txt
12
+ NumOpt.egg-info/top_level.txt
13
+ NumOpt/FSI/__init__.py
14
+ NumOpt/FSI/tools.py
15
+ NumOpt/nx/__init__.py
16
+ NumOpt/nx/tools.py
numopt-0.0.3/PKG-INFO ADDED
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: NumOpt
3
+ Version: 0.0.3
4
+ Summary: pti is a Python package that helps you design and optimize engineered systems.
5
+ Home-page: https://github.com/Zcaic/NumOpt.git
6
+ Author: Zcaic
7
+ License: MIT License
8
+
9
+ Copyright (c) 2019-2023 Peter Sharpe
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Project-URL: homepage, https://github.com/Zcaic/NumOpt.git
29
+ Keywords: optimization,automatic,differentiation
30
+ Classifier: Development Status :: 5 - Production/Stable
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: Topic :: Scientific/Engineering :: Physics
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3
35
+ Requires-Python: >=3.9
36
+ Description-Content-Type: text/markdown
37
+ License-File: LICENSE.txt
38
+ Requires-Dist: aerosandbox>=4.2.8
39
+ Requires-Dist: termcolor>=3.1.0
40
+ Dynamic: home-page
41
+ Dynamic: license-file
42
+ Dynamic: requires-python
43
+
44
+ **NumOpt is a Numerical Optimization Tool Python package that helps you design and optimize engineered systems.**
45
+
46
+ ```
47
+ pip install NumOpt
48
+ ```
@@ -0,0 +1,32 @@
1
+ [project]
2
+ name = "NumOpt"
3
+ description = "pti is a Python package that helps you design and optimize engineered systems."
4
+ authors = [{ name = "Zcaic"}]
5
+ readme = "README.md"
6
+ license = {file="LICENSE.txt"}
7
+ classifiers = [
8
+ 'Development Status :: 5 - Production/Stable',
9
+ 'Intended Audience :: Science/Research',
10
+ 'Topic :: Scientific/Engineering :: Physics',
11
+ 'License :: OSI Approved :: MIT License',
12
+ 'Programming Language :: Python :: 3',
13
+ ]
14
+ keywords = ["optimization", "automatic", "differentiation"]
15
+ dynamic = ["version"]
16
+ urls = { homepage = "https://github.com/Zcaic/NumOpt.git" }
17
+ requires-python = ">= 3.9"
18
+ dependencies = [
19
+ 'aerosandbox >= 4.2.8',
20
+ "termcolor >= 3.1.0"
21
+ ]
22
+
23
+ [build-system]
24
+ requires = ["setuptools>=77"]
25
+ build-backend = "setuptools.build_meta"
26
+
27
+ [tool.setuptools.dynamic]
28
+ version = { attr = "NumOpt.__init__.__version__" }
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["."]
32
+ include = ["NumOpt*"]
@@ -1,3 +0,0 @@
1
- from NumOpt.opti import *
2
-
3
- __version__ = "0.0.1"
@@ -1,31 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: NumOpt
3
- Version: 0.0.1
4
- Summary: Opti is a Python package that helps you design and optimize engineered systems.
5
- Home-page: https://github.com/Zcaic/NumOpt.git
6
- Author: Zcaic
7
- Keywords: optimization automatic differentiation
8
- Classifier: Development Status :: 5 - Production/Stable
9
- Classifier: Intended Audience :: Science/Research
10
- Classifier: Topic :: Scientific/Engineering :: Physics
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Programming Language :: Python :: 3
13
- Requires-Python: >=3.9
14
- License-File: LICENSE.txt
15
- Requires-Dist: aerosandbox>=4.2.8
16
- Requires-Dist: termcolor>=3.1.0
17
- Dynamic: author
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: home-page
21
- Dynamic: keywords
22
- Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
-
27
- **NumOpt is a Numerical Optimization Tool Python package that helps you design and optimize engineered systems.**
28
-
29
- ```
30
- pip install NumOpt
31
- ```
numopt-0.0.1/PKG-INFO DELETED
@@ -1,31 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: NumOpt
3
- Version: 0.0.1
4
- Summary: Opti is a Python package that helps you design and optimize engineered systems.
5
- Home-page: https://github.com/Zcaic/NumOpt.git
6
- Author: Zcaic
7
- Keywords: optimization automatic differentiation
8
- Classifier: Development Status :: 5 - Production/Stable
9
- Classifier: Intended Audience :: Science/Research
10
- Classifier: Topic :: Scientific/Engineering :: Physics
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Programming Language :: Python :: 3
13
- Requires-Python: >=3.9
14
- License-File: LICENSE.txt
15
- Requires-Dist: aerosandbox>=4.2.8
16
- Requires-Dist: termcolor>=3.1.0
17
- Dynamic: author
18
- Dynamic: classifier
19
- Dynamic: description
20
- Dynamic: home-page
21
- Dynamic: keywords
22
- Dynamic: license-file
23
- Dynamic: requires-dist
24
- Dynamic: requires-python
25
- Dynamic: summary
26
-
27
- **NumOpt is a Numerical Optimization Tool Python package that helps you design and optimize engineered systems.**
28
-
29
- ```
30
- pip install NumOpt
31
- ```
File without changes
File without changes
File without changes
File without changes