LumAPI 1.0.0__tar.gz → 1.0.2__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.
@@ -0,0 +1,3 @@
1
+ from LumAPI.lumapi import *
2
+
3
+
@@ -6,7 +6,7 @@ import platform
6
6
  import sys
7
7
 
8
8
  # --- 路径处理逻辑 ---
9
- # 对于安装版,cli.py 位于 lumapi 包内部
9
+ # 对于安装版,cli.py 位于 LumAPI 包内部
10
10
  LUMAPI_DIR = os.path.dirname(os.path.abspath(__file__))
11
11
  CONFIG_PATH = os.path.join(LUMAPI_DIR, "config.json")
12
12
  INIT_PATH = os.path.join(LUMAPI_DIR, "__init__.py")
@@ -14,7 +14,7 @@ INIT_PATH = os.path.join(LUMAPI_DIR, "__init__.py")
14
14
  # 确保 __init__.py 存在
15
15
  if not os.path.exists(INIT_PATH):
16
16
  try:
17
- with open(INIT_PATH, 'w') as f: f.write("from lumapi.lumapi import *\n")
17
+ with open(INIT_PATH, 'w') as f: f.write("from LumAPI.lumapi import *\n")
18
18
  except: pass
19
19
  # ---------------------------
20
20
 
@@ -128,7 +128,7 @@ def load_config():
128
128
 
129
129
  def load_lumapi(lumerical_path, version):
130
130
  # 直接使用 validate_path 里的逻辑来测试
131
- # 或者尝试从 lumapi 包导入
131
+ # 或者尝试从 LumAPI 包导入
132
132
  try:
133
133
  print(f"正在尝试加载 Lumerical API ({version})...")
134
134
  path, ver = validate_path(lumerical_path)
@@ -0,0 +1,4 @@
1
+ {
2
+ "lumerical_path": "D:\\Program Files\\Lumerical",
3
+ "version": "v241"
4
+ }
@@ -15,7 +15,7 @@ class LumericalGUI:
15
15
  self.root.title("Lumerical 接口配置工具 (PyPI版)")
16
16
 
17
17
  # --- 路径处理核心逻辑 ---
18
- # 对于安装版,gui.py 位于 lumapi 包内部
18
+ # 对于安装版,gui.py 位于 LumAPI 包内部
19
19
  self.lumapi_dir = os.path.dirname(os.path.abspath(__file__))
20
20
  self.config_path = os.path.join(self.lumapi_dir, "config.json")
21
21
  self.init_file_path = os.path.join(self.lumapi_dir, "__init__.py")
@@ -24,7 +24,7 @@ class LumericalGUI:
24
24
  if not os.path.exists(self.init_file_path):
25
25
  try:
26
26
  with open(self.init_file_path, 'w') as f:
27
- f.write("from lumapi.lumapi import *\n")
27
+ f.write("from LumAPI.lumapi import *\n")
28
28
  except: pass
29
29
 
30
30
  self.create_widgets()
@@ -195,7 +195,7 @@ class LumericalGUI:
195
195
  try:
196
196
  # 重新加载模块以应用新配置 (如果lumapi本身有缓存)
197
197
  # 这里简单尝试验证路径
198
- from lumapi.lumapi import validate_path
198
+ from LumAPI.lumapi import validate_path
199
199
  path = self.path_var.get()
200
200
  version = self.detect_version(path)
201
201
 
@@ -489,104 +489,136 @@ def RorySommerfeld_Vector(lamb, x_near, y_near, E_near_x, E_near_y, x_far, y_far
489
489
  return E_far, E_far_x, E_far_y, E_far_z
490
490
 
491
491
 
492
- class LumAPI:
492
+ class lumerical:
493
493
  def __init__(self, lumerical_path='', version='', config_path=CONFIG_PATH):
494
494
  self.config_path = config_path
495
-
496
- # 如果没有提供路径,尝试从配置文件加载
497
- if not lumerical_path:
498
- try:
499
- with open(self.config_path, 'r') as f:
500
- config = json.load(f)
501
- lumerical_path = config.get('lumerical_path')
502
- version = config.get('version')
503
-
504
- if not lumerical_path:
505
- raise ValueError("配置文件中缺少lumerical_path字段")
506
-
507
- except Exception as e:
508
- raise ValueError(f"配置文件读取失败: {str(e)}")
509
-
510
- # 验证路径
511
- self.lumapi = validate_path(lumerical_path, version)
512
-
513
- # 检测路径是否有效
514
- if not self.lumapi:
515
- raise ValueError(f"错误:Lumerical路径无效,请检查路径{lumerical_path}和版本{version}")
516
-
495
+ self.lumapi = None
517
496
  self.lumerical_path = lumerical_path
518
497
  self.version = version
519
-
520
- def FDTD(self, filename=None, key = None, hide = False, serverArgs = {}, remoteArgs = {}, **kwargs):
498
+
499
+ # 尝试加载配置
500
+ self._load_config()
501
+
502
+ def _load_config(self):
503
+ """内部方法:尝试从参数或配置文件加载 lumapi"""
504
+ try:
505
+ path = self.lumerical_path
506
+ ver = self.version
507
+
508
+ # 如果初始化时没给路径,尝试读配置
509
+ if not path:
510
+ if os.path.exists(self.config_path):
511
+ with open(self.config_path, 'r', encoding='utf-8') as f:
512
+ config = json.load(f)
513
+ path = config.get('lumerical_path')
514
+ ver = config.get('version')
515
+
516
+ if path:
517
+ self.lumapi = validate_path(path, ver)
518
+ self.lumerical_path = path
519
+ self.version = ver
520
+ except Exception:
521
+ self.lumapi = None
522
+
523
+ def _check_config_and_prompt(self):
524
+ """核心逻辑:检查配置状态,若无效则引导用户使用 LumAPI 命令"""
525
+ if self.lumapi is None:
526
+ print("\n" + "*" * 60)
527
+ print("【配置错误】未检测到有效的 Lumerical 环境。")
528
+ print("原因可能是:")
529
+ print("1. 尚未进行初始化配置。")
530
+ print("2. 配置文件 config.json 损坏或路径已失效。")
531
+ print("\n请在终端执行以下命令进行配置:")
532
+ print(" LumAPI")
533
+ print("或者使用命令行配置程序:")
534
+ print(" LumAPI_CLI")
535
+ print("*" * 60 + "\n")
536
+ # 退出程序或抛出异常,防止后续调用崩溃
537
+ sys.exit(1)
538
+
539
+ def FDTD(self, filename=None, key=None, hide=False, serverArgs={}, remoteArgs={}, **kwargs):
540
+ self._check_config_and_prompt()
521
541
  return FDTD(self.lumapi, filename, key, hide, serverArgs, remoteArgs, **kwargs)
522
542
 
523
- def MODE(self, filename=None, key = None, hide = False, serverArgs = {}, remoteArgs = {}, **kwargs):
543
+ def MODE(self, filename=None, key=None, hide=False, serverArgs={}, remoteArgs={}, **kwargs):
544
+ self._check_config_and_prompt()
524
545
  return MODE(self.lumapi, filename, key, hide, serverArgs, remoteArgs, **kwargs)
525
546
 
526
- def DEVICE(self, filename=None, key = None, hide = False, serverArgs = {}, remoteArgs = {}, **kwargs):
527
- return MODE(self.lumapi, filename, key, hide, serverArgs, remoteArgs, **kwargs)
547
+ def DEVICE(self, filename=None, key=None, hide=False, serverArgs={}, remoteArgs={}, **kwargs):
548
+ self._check_config_and_prompt()
549
+ return DEVICE(self.lumapi, filename, key, hide, serverArgs, remoteArgs, **kwargs)
528
550
 
529
- def INTERCONNECT(self, filename=None, key = None, hide = False, serverArgs = {}, remoteArgs = {}, **kwargs):
530
- return MODE(self.lumapi, filename, key, hide, serverArgs, remoteArgs, **kwargs)
531
-
532
- class FDTD():
533
- def __init__(self, lumapi, filename=None, key = None, hide = False, serverArgs = {}, remoteArgs = {}, **kwargs):
534
- self.lumapi = lumapi
535
- self.filename = filename
536
-
537
- self.fdtd = lumapi.FDTD(filename, key, hide, serverArgs, remoteArgs, **kwargs)
551
+ def INTERCONNECT(self, filename=None, key=None, hide=False, serverArgs={}, remoteArgs={}, **kwargs):
552
+ self._check_config_and_prompt()
553
+ return INTERCONNECT(self.lumapi, filename, key, hide, serverArgs, remoteArgs, **kwargs)
554
+
555
+ class LumFuncBase:
556
+ """Lumerical 功能基类,处理通用的 API 转发和参数预处理"""
557
+ def __init__(self, target_handle):
558
+ # 隐藏内部句柄,避免与转发逻辑冲突
559
+ self._handle = target_handle
560
+
561
+ def _process_arg(self, arg):
562
+ """
563
+ 核心预处理逻辑:
564
+ 1. 整型 ndarray -> 浮点型
565
+ 2. 一维 ndarray (len > 1) -> 二维 [[...]]
566
+ """
567
+ if isinstance(arg, np.ndarray):
568
+ # 规则 1: 检查是否为整型数组并转换
569
+ if np.issubdtype(arg.dtype, np.integer):
570
+ arg = arg.astype(float)
571
+
572
+ # 规则 2: 检查一维数组且长度不为 1,进行升维
573
+ if arg.ndim == 1 and arg.shape[0] != 1:
574
+ arg = arg[np.newaxis, :]
575
+ return arg
538
576
 
539
577
  def __getattr__(self, name):
540
- '''
541
- 将原本函数转发回去
542
- '''
543
- return getattr(self.fdtd, name)
544
-
545
- class MODE():
546
- def __init__(self, lumapi, filename=None, key = None, hide = False, serverArgs = {}, remoteArgs = {}, **kwargs):
547
- self.lumapi = lumapi
548
- self.filename = filename
578
+ # 从 Lumerical 原始句柄中获取属性或方法
579
+ attr = getattr(self._handle, name)
549
580
 
550
- if not filename:
551
- self.mode = lumapi.MODE()
552
- else:
553
- self.mode = lumapi.MODE(filename, key, hide, serverArgs, remoteArgs, **kwargs)
554
-
555
- def __getattr__(self, name):
556
- '''
557
- 将原本函数转发回去
558
- '''
559
- return getattr(self.mode, name)
581
+ # 如果不是可调用对象(如变量、常量),直接返回
582
+ if not callable(attr):
583
+ return attr
584
+
585
+ # 如果是方法,返回包装函数进行参数拦截处理
586
+ def wrapper(*args, **kwargs):
587
+ # 处理位置参数
588
+ new_args = tuple(self._process_arg(arg) for arg in args)
589
+ # 处理关键字参数
590
+ new_kwargs = {k: self._process_arg(v) for k, v in kwargs.items()}
591
+
592
+ # 调用原始 API 并返回结果
593
+ return attr(*new_args, **new_kwargs)
594
+
595
+ return wrapper
560
596
 
561
- class DEVICE():
562
- def __init__(self, lumapi, filename=None, key = None, hide = False, serverArgs = {}, remoteArgs = {}, **kwargs):
563
- self.lumapi = lumapi
597
+ class FDTD(LumFuncBase):
598
+ def __init__(self, lumapi, filename=None, key=None, hide=False, serverArgs={}, remoteArgs={}, **kwargs):
599
+ handle = lumapi.FDTD(filename, key, hide, serverArgs, remoteArgs, **kwargs)
600
+ super().__init__(handle)
564
601
  self.filename = filename
565
-
566
- if not filename:
567
- self.device = lumapi.DEVICE()
568
- else:
569
- self.device = lumapi.DEVICE(filename, key, hide, serverArgs, remoteArgs, **kwargs)
570
602
 
571
- def __getattr__(self, name):
572
- '''
573
- 将原本函数转发回去
574
- '''
575
- return getattr(self.device, name)
576
-
577
- class INTERCONNECT():
578
- def __init__(self, lumapi, filename=None, key = None, hide = False, serverArgs = {}, remoteArgs = {}, **kwargs):
579
- self.lumapi = lumapi
603
+ class MODE(LumFuncBase):
604
+ def __init__(self, lumapi, filename=None, key=None, hide=False, serverArgs={}, remoteArgs={}, **kwargs):
605
+ handle = lumapi.MODE(filename, key, hide, serverArgs, remoteArgs, **kwargs)
606
+ super().__init__(handle)
580
607
  self.filename = filename
581
-
582
- self.interconnect = lumapi.INTERCONNECT(filename, key, hide, serverArgs, remoteArgs, **kwargs)
583
608
 
584
- def __getattr__(self, name):
585
- '''
586
- 将原本函数转发回去
587
- '''
588
- return getattr(self.interconnect, name)
609
+ class DEVICE(LumFuncBase):
610
+ def __init__(self, lumapi, filename=None, key=None, hide=False, serverArgs={}, remoteArgs={}, **kwargs):
611
+ handle = lumapi.DEVICE(filename, key, hide, serverArgs, remoteArgs, **kwargs)
612
+ super().__init__(handle)
613
+ self.filename = filename
589
614
 
615
+ class INTERCONNECT(LumFuncBase):
616
+ def __init__(self, lumapi, filename=None, key=None, hide=False, serverArgs={}, remoteArgs={}, **kwargs):
617
+ handle = lumapi.INTERCONNECT(filename, key, hide, serverArgs, remoteArgs, **kwargs)
618
+ super().__init__(handle)
619
+ self.filename = filename
620
+
621
+ lumapi = lumerical()
590
622
 
591
623
  if __name__ == '__main__':
592
624
  um = 1e-6
@@ -594,7 +626,7 @@ if __name__ == '__main__':
594
626
  S = 0.5*um
595
627
  material_base = 'Au (Gold) - CRC'
596
628
 
597
- lumapi = LumAPI()
629
+ lumapi = lumapi()
598
630
  fdtd = lumapi.FDTD()
599
631
  fdtd.addrect(
600
632
  name="base",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: LumAPI
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: Lumerical Python API 自动化配置工具
5
5
  Requires-Python: >=3.7
6
6
  Description-Content-Type: text/markdown
@@ -25,6 +25,57 @@ Dynamic: license-file
25
25
 
26
26
  ## 🚀 快速开始
27
27
 
28
+ ## 📦 pip安装(推荐)
29
+
30
+ ### 1. 库文件下载
31
+ 通过运行以下命令安装`LumAPI`库
32
+ ```bash
33
+ pip install LumAPI
34
+ ```
35
+ ### 2. 配置lumerical路径
36
+ 在安装完库后运行下面的命令即可打开lumerical路径配置页面
37
+ 图形界面配置:
38
+ ```bash
39
+ LumAPI
40
+ ```
41
+ 命令行配置:
42
+ ```bash
43
+ LumAPI_CLI
44
+ ```
45
+ ### 3. 使用
46
+ 通过下述代码即可调用 Lumerical API:
47
+ ```python
48
+ from LumAPI import *
49
+
50
+ filename = 'simulation.fsp'
51
+ fdtd = lumapi.FDTD(filename)
52
+ fdtd.close()
53
+ ```
54
+ 或者不进行lumerical配置,直接传入lumerical路径:
55
+ ```python
56
+ from LumAPI import *
57
+ lumerical_path = 'C:/Program Files/Lumerical'
58
+ version = 'v241'
59
+ fdtd = lumerical(lumerical_path=lumerical_path, version=version).FDTD(filename)
60
+ fdtd.close()
61
+ ```
62
+ 或者传入config.json路径:
63
+ ```python
64
+ from LumAPI import *
65
+ config_path = './config.json'
66
+ fdtd = lumerical(config_path=config_path).FDTD(filename)
67
+ fdtd.close()
68
+ ```
69
+ 其中config.json文件内容如下:
70
+ ```python
71
+ {
72
+ "lumerical_path": "C:\\Program Files\\Lumerical",
73
+ "version": "v241"
74
+ }
75
+ ```
76
+
77
+ ## 📦 打包程序安装
78
+
28
79
  ### 1. 获取程序
29
80
  请前往 [Releases 页面](releases) 下载适配您操作系统(Windows/Linux)及架构(AMD64/ARM64)的预编译程序。`LumAPI_GUI`为带图形界面版本的配置程序,`LumAPI_CLI`为无图形界面版本的命令行配置工具,二者选择其一即可。
30
81
 
@@ -38,14 +89,14 @@ Dynamic: license-file
38
89
 
39
90
  ## 🛠️ 集成模式
40
91
 
41
- 配置完成后,本工具提供两种方式将 Lumerical API (`lumapi`) 接入您的开发环境。
92
+ 配置完成后,本工具提供两种方式将 Lumerical API (`LumAPI`) 接入您的开发环境。
42
93
 
43
94
  ### 方式一:全局集成(推荐)
44
- 适用于希望在任意路径下直接调用 `lumapi` 的场景。
95
+ 适用于希望在任意路径下直接调用 `LumAPI` 的场景。
45
96
  1. **选择解释器**:在配置工具中指定您日常使用的 Python 解释器路径(支持自动扫描 Conda/System Python)。
46
97
  2. **一键注入**:点击 **“导出到 Python 解释器”**。
47
98
  * *机制*:工具会将库文件自动部署至该解释器的 `site-packages` 目录。
48
- * *效果*:无需额外操作,直接在代码中使用 `import lumapi` 即可。
99
+ * *效果*:无需额外操作,直接在代码中使用 `import LumAPI` 即可。
49
100
 
50
101
  ### 方式二:项目级集成(便携模式)
51
102
  适用于临时测试或需随项目打包分发的场景。
@@ -66,7 +117,7 @@ Dynamic: license-file
66
117
 
67
118
  **代码示例:**
68
119
  ```python
69
- import lumapi.LumAPI as lumapi # 根据实际导出结构调整导入路径
120
+ from LumAPI import lumapi
70
121
 
71
122
  # 定义基础参数
72
123
  um = 1e-6
@@ -123,7 +174,7 @@ def Kirchhoff(lamb, x_near, y_near, E_near, x_far, y_far, z_far, mode='numba'):
123
174
  ```python
124
175
  import numpy as np
125
176
  import matplotlib.pyplot as plt
126
- from lumapi import Kirchhoff
177
+ from LumAPI import Kirchhoff
127
178
 
128
179
  # 1. 定义物理常数与网格
129
180
  um = 1e-6
@@ -1,14 +1,15 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
+ LumAPI/__init__.py
5
+ LumAPI/cli.py
6
+ LumAPI/config.json
7
+ LumAPI/gui.py
8
+ LumAPI/lumapi.py
4
9
  LumAPI.egg-info/PKG-INFO
5
10
  LumAPI.egg-info/SOURCES.txt
6
11
  LumAPI.egg-info/dependency_links.txt
7
12
  LumAPI.egg-info/entry_points.txt
8
13
  LumAPI.egg-info/requires.txt
9
14
  LumAPI.egg-info/top_level.txt
10
- lumapi/__init__.py
11
- lumapi/cli.py
12
- lumapi/config.json
13
- lumapi/gui.py
14
- lumapi/lumapi.py
15
+ test/test.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ LumAPI = LumAPI.gui:main
3
+ LumAPI_CLI = LumAPI.cli:main
@@ -0,0 +1 @@
1
+ LumAPI
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: LumAPI
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: Lumerical Python API 自动化配置工具
5
5
  Requires-Python: >=3.7
6
6
  Description-Content-Type: text/markdown
@@ -25,6 +25,57 @@ Dynamic: license-file
25
25
 
26
26
  ## 🚀 快速开始
27
27
 
28
+ ## 📦 pip安装(推荐)
29
+
30
+ ### 1. 库文件下载
31
+ 通过运行以下命令安装`LumAPI`库
32
+ ```bash
33
+ pip install LumAPI
34
+ ```
35
+ ### 2. 配置lumerical路径
36
+ 在安装完库后运行下面的命令即可打开lumerical路径配置页面
37
+ 图形界面配置:
38
+ ```bash
39
+ LumAPI
40
+ ```
41
+ 命令行配置:
42
+ ```bash
43
+ LumAPI_CLI
44
+ ```
45
+ ### 3. 使用
46
+ 通过下述代码即可调用 Lumerical API:
47
+ ```python
48
+ from LumAPI import *
49
+
50
+ filename = 'simulation.fsp'
51
+ fdtd = lumapi.FDTD(filename)
52
+ fdtd.close()
53
+ ```
54
+ 或者不进行lumerical配置,直接传入lumerical路径:
55
+ ```python
56
+ from LumAPI import *
57
+ lumerical_path = 'C:/Program Files/Lumerical'
58
+ version = 'v241'
59
+ fdtd = lumerical(lumerical_path=lumerical_path, version=version).FDTD(filename)
60
+ fdtd.close()
61
+ ```
62
+ 或者传入config.json路径:
63
+ ```python
64
+ from LumAPI import *
65
+ config_path = './config.json'
66
+ fdtd = lumerical(config_path=config_path).FDTD(filename)
67
+ fdtd.close()
68
+ ```
69
+ 其中config.json文件内容如下:
70
+ ```python
71
+ {
72
+ "lumerical_path": "C:\\Program Files\\Lumerical",
73
+ "version": "v241"
74
+ }
75
+ ```
76
+
77
+ ## 📦 打包程序安装
78
+
28
79
  ### 1. 获取程序
29
80
  请前往 [Releases 页面](releases) 下载适配您操作系统(Windows/Linux)及架构(AMD64/ARM64)的预编译程序。`LumAPI_GUI`为带图形界面版本的配置程序,`LumAPI_CLI`为无图形界面版本的命令行配置工具,二者选择其一即可。
30
81
 
@@ -38,14 +89,14 @@ Dynamic: license-file
38
89
 
39
90
  ## 🛠️ 集成模式
40
91
 
41
- 配置完成后,本工具提供两种方式将 Lumerical API (`lumapi`) 接入您的开发环境。
92
+ 配置完成后,本工具提供两种方式将 Lumerical API (`LumAPI`) 接入您的开发环境。
42
93
 
43
94
  ### 方式一:全局集成(推荐)
44
- 适用于希望在任意路径下直接调用 `lumapi` 的场景。
95
+ 适用于希望在任意路径下直接调用 `LumAPI` 的场景。
45
96
  1. **选择解释器**:在配置工具中指定您日常使用的 Python 解释器路径(支持自动扫描 Conda/System Python)。
46
97
  2. **一键注入**:点击 **“导出到 Python 解释器”**。
47
98
  * *机制*:工具会将库文件自动部署至该解释器的 `site-packages` 目录。
48
- * *效果*:无需额外操作,直接在代码中使用 `import lumapi` 即可。
99
+ * *效果*:无需额外操作,直接在代码中使用 `import LumAPI` 即可。
49
100
 
50
101
  ### 方式二:项目级集成(便携模式)
51
102
  适用于临时测试或需随项目打包分发的场景。
@@ -66,7 +117,7 @@ Dynamic: license-file
66
117
 
67
118
  **代码示例:**
68
119
  ```python
69
- import lumapi.LumAPI as lumapi # 根据实际导出结构调整导入路径
120
+ from LumAPI import lumapi
70
121
 
71
122
  # 定义基础参数
72
123
  um = 1e-6
@@ -123,7 +174,7 @@ def Kirchhoff(lamb, x_near, y_near, E_near, x_far, y_far, z_far, mode='numba'):
123
174
  ```python
124
175
  import numpy as np
125
176
  import matplotlib.pyplot as plt
126
- from lumapi import Kirchhoff
177
+ from LumAPI import Kirchhoff
127
178
 
128
179
  # 1. 定义物理常数与网格
129
180
  um = 1e-6
@@ -11,6 +11,57 @@
11
11
 
12
12
  ## 🚀 快速开始
13
13
 
14
+ ## 📦 pip安装(推荐)
15
+
16
+ ### 1. 库文件下载
17
+ 通过运行以下命令安装`LumAPI`库
18
+ ```bash
19
+ pip install LumAPI
20
+ ```
21
+ ### 2. 配置lumerical路径
22
+ 在安装完库后运行下面的命令即可打开lumerical路径配置页面
23
+ 图形界面配置:
24
+ ```bash
25
+ LumAPI
26
+ ```
27
+ 命令行配置:
28
+ ```bash
29
+ LumAPI_CLI
30
+ ```
31
+ ### 3. 使用
32
+ 通过下述代码即可调用 Lumerical API:
33
+ ```python
34
+ from LumAPI import *
35
+
36
+ filename = 'simulation.fsp'
37
+ fdtd = lumapi.FDTD(filename)
38
+ fdtd.close()
39
+ ```
40
+ 或者不进行lumerical配置,直接传入lumerical路径:
41
+ ```python
42
+ from LumAPI import *
43
+ lumerical_path = 'C:/Program Files/Lumerical'
44
+ version = 'v241'
45
+ fdtd = lumerical(lumerical_path=lumerical_path, version=version).FDTD(filename)
46
+ fdtd.close()
47
+ ```
48
+ 或者传入config.json路径:
49
+ ```python
50
+ from LumAPI import *
51
+ config_path = './config.json'
52
+ fdtd = lumerical(config_path=config_path).FDTD(filename)
53
+ fdtd.close()
54
+ ```
55
+ 其中config.json文件内容如下:
56
+ ```python
57
+ {
58
+ "lumerical_path": "C:\\Program Files\\Lumerical",
59
+ "version": "v241"
60
+ }
61
+ ```
62
+
63
+ ## 📦 打包程序安装
64
+
14
65
  ### 1. 获取程序
15
66
  请前往 [Releases 页面](releases) 下载适配您操作系统(Windows/Linux)及架构(AMD64/ARM64)的预编译程序。`LumAPI_GUI`为带图形界面版本的配置程序,`LumAPI_CLI`为无图形界面版本的命令行配置工具,二者选择其一即可。
16
67
 
@@ -24,14 +75,14 @@
24
75
 
25
76
  ## 🛠️ 集成模式
26
77
 
27
- 配置完成后,本工具提供两种方式将 Lumerical API (`lumapi`) 接入您的开发环境。
78
+ 配置完成后,本工具提供两种方式将 Lumerical API (`LumAPI`) 接入您的开发环境。
28
79
 
29
80
  ### 方式一:全局集成(推荐)
30
- 适用于希望在任意路径下直接调用 `lumapi` 的场景。
81
+ 适用于希望在任意路径下直接调用 `LumAPI` 的场景。
31
82
  1. **选择解释器**:在配置工具中指定您日常使用的 Python 解释器路径(支持自动扫描 Conda/System Python)。
32
83
  2. **一键注入**:点击 **“导出到 Python 解释器”**。
33
84
  * *机制*:工具会将库文件自动部署至该解释器的 `site-packages` 目录。
34
- * *效果*:无需额外操作,直接在代码中使用 `import lumapi` 即可。
85
+ * *效果*:无需额外操作,直接在代码中使用 `import LumAPI` 即可。
35
86
 
36
87
  ### 方式二:项目级集成(便携模式)
37
88
  适用于临时测试或需随项目打包分发的场景。
@@ -52,7 +103,7 @@
52
103
 
53
104
  **代码示例:**
54
105
  ```python
55
- import lumapi.LumAPI as lumapi # 根据实际导出结构调整导入路径
106
+ from LumAPI import lumapi
56
107
 
57
108
  # 定义基础参数
58
109
  um = 1e-6
@@ -109,7 +160,7 @@ def Kirchhoff(lamb, x_near, y_near, E_near, x_far, y_far, z_far, mode='numba'):
109
160
  ```python
110
161
  import numpy as np
111
162
  import matplotlib.pyplot as plt
112
- from lumapi import Kirchhoff
163
+ from LumAPI import Kirchhoff
113
164
 
114
165
  # 1. 定义物理常数与网格
115
166
  um = 1e-6
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "LumAPI"
7
- version = "1.0.0"
7
+ version = "1.0.2"
8
8
  description = "Lumerical Python API 自动化配置工具"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -18,16 +18,16 @@ dependencies = [
18
18
 
19
19
  # 定义命令行入口,分别指向文件夹内部的新脚本
20
20
  [project.scripts]
21
- LumAPI = "lumapi.gui:main"
22
- LumAPI_CLI = "lumapi.cli:main"
21
+ LumAPI = "LumAPI.gui:main"
22
+ LumAPI_CLI = "LumAPI.cli:main"
23
23
 
24
24
  [tool.setuptools]
25
- # 明确指定只包含名为 lumapi 的文件夹
26
- packages = ["lumapi"]
25
+ # 明确指定只包含名为 LumAPI 的文件夹
26
+ packages = ["LumAPI"]
27
27
 
28
28
  [tool.setuptools.package-data]
29
29
  # 确保 config.json 被包含在内
30
- lumapi = ["*.json"]
30
+ LumAPI = ["*.json"]
31
31
 
32
32
  # 排除根目录下的旧脚本
33
33
  [tool.setuptools.exclude-package-data]
@@ -0,0 +1,13 @@
1
+ from LumAPI import *
2
+
3
+ fdtd = lumapi.FDTD()
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- LumAPI = lumapi.gui:main
3
- LumAPI_CLI = lumapi.cli:main
@@ -1 +0,0 @@
1
- lumapi
@@ -1,3 +0,0 @@
1
- from lumapi.lumapi import *
2
-
3
-
File without changes
File without changes
File without changes