Skip to main content

A Python client library for Osis APDL

Project description

pyosis

中交公路规划设计院自研OSIS桥隧分析平台的Python接口库pyosis

Installation

由于pyosis存在重名,请您采用以下方式安装:

pip install osis-python

如果您的镜像站未同步pyosis,请使用以下命令:

pip install osis-python -i https://pypi.org/simple

Usage

首先需要安装最新版OSIS(>=5.0),并配置好python环境变量。pyosis需要python3.11版本以上的环境。并且,您需要在环境变量中设置PYTHONHOME为您python的安装目录,例如:C:\Program Files\python,设置PYTHONIOENCODINGutf-8。然后在path中分别添加%PYTHONHOME%%PYTHONHOME%\Scripts两个条目。

您的脚本应放置于OSIS安装目录下的python文件夹中,例如:C:\Program Files\osis\python。假设存在一个名为test_osis.py的脚本,其内容如下:

import json
from pyosis.core import osis_run    # 导入需要的功能
from pyosis.control import *
from pyosis.general import *
from pyosis.section import *
from pyosis.material import *
from pyosis.node import *
from pyosis.element import *
from pyosis.boundary import *
from pyosis.load import *
from pyosis.post import *

osis_clear()

osis_acel(9.8066)
osis_calc_tendon(1)
osis_calc_con_force(1)
osis_calc_shrink(1)
osis_calc_creep(1)
osis_calc_shear(1)
osis_calc_rlx(1)
osis_mod_loc_coor(0)
osis_inc_tendon(1)
osis_nl(0, 0)
osis_ln_srch(0)
osis_auto_ts(0)
osis_mod_opt(0)

osis_section_circle(1, "圆形截面1", "CIRCLE", "Hollow", 0.219, 0.012)
osis_section_circle(2, "圆形截面2", "CIRCLE", "Hollow", 0.180, 0.008)
osis_section_circle(3, "圆形截面3", "CIRCLE", "Hollow", 0.114, 0.005)
osis_section_circle(4, "圆形截面4", "CIRCLE", "Hollow", 0.089, 0.004)
osis_section_circle(5, "圆形截面5", "CIRCLE", "Hollow", 0.045, 0.003)

osis_material_steel(1, "钢材1", "STEEL", "JTGD64_2015", "Q345", 0.05)

# 固定节点(x,y单位:m)
osis_node(1, 0, 5, 0)
osis_node(2, 15, 5, 0)
# 荷载作用节点
osis_node(3, 7.5, 0, 0)
osis_node(4, 20, 0, 0)

osis_element_beam3d(1, "BEAM3D", 1, 3, 1, 4, 4, 1, 1, 0.00, 0, 0.00, 0)
osis_element_beam3d(2, "BEAM3D", 2, 3, 1, 5, 5, 1, 1, 0.00, 0, 0.00, 0)
osis_element_beam3d(3, "BEAM3D", 2, 4, 1, 5, 5, 1, 1, 0.00, 0, 0.00, 0)
osis_element_beam3d(4, "BEAM3D", 3, 4, 1, 5, 5, 1, 1, 0.00, 0, 0.00, 0)


osis_boundary_general(1, "GENERAL", "", 1, 1, 1, 1, 1, 1, 1)
osis_assign_boundary(1, "a", [1, 2])

osis_loadcase("自定义工况1", "USER", 1, "施加于节点3和4的两个力")
osis_load_nforce("NFORCE", "自定义工况1", 3, 0, -1000000, 0, 0, 0, 0)
osis_load_nforce("NFORCE", "自定义工况1", 4, 200000, 0, 0, 0, 0, 0)

osis_solve()

osis_run()      # 让OSIS执行所有前处理命令

isok, error, ef = osis_elem_force("自定义工况1", "EF", "BEAM3D")


def dict_to_json_txt(data, filename):
    """将字典以JSON格式写入文件"""
    with open(filename, 'w', encoding='utf-8') as f:
        json.dump(data, f, indent=4)
    
    print(f"字典已写入文件: {filename}")

# 使用
dict_to_json_txt(ef, "output.json")

在OSIS中选择并运行这个脚本,如果一切正常的话,您将会看到OSIS开始了计算,并在C:\Program Files\osis下生成了一个名为output.json的文件,其中包含了OSIS计算内力的结果。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osis_python-0.1.1.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osis_python-0.1.1-py3-none-any.whl (50.5 kB view details)

Uploaded Python 3

File details

Details for the file osis_python-0.1.1.tar.gz.

File metadata

  • Download URL: osis_python-0.1.1.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for osis_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9a151e14b7744b1431c4ccb40a263c25bab23ea8794467a3e40a997dba801af8
MD5 3a7baeef7ddaa383f1385a9163d5f2c5
BLAKE2b-256 f4f0624ce75c348f1fa37414ded0078a6cb56ab9c8c245b5699d85028fd99e21

See more details on using hashes here.

File details

Details for the file osis_python-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: osis_python-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 50.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for osis_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3bd44b6466607be21ed709e3961c7599971a9768c4f491344b1549e23a95f3cf
MD5 88200e224d69b9891d309c03ef7d01d1
BLAKE2b-256 d8a283375129bf553afebe8f24e5788aa10df82b90ee6e4eedd307947a9165fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page