Skip to content
Open
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5b5d11e
refactor BaseSensorClass
StefanThoene Aug 1, 2025
0990b59
refactor SourceLuminaire
Aug 2, 2025
e151c5d
refactor the spectrum.py
Aug 5, 2025
2112d08
refactor the luminaire source class
Aug 5, 2025
1b62c6d
luminaire and spectrum constant values in constants.py
Aug 5, 2025
e8d2d27
update the test related to luminaire source class
Aug 5, 2025
c11dc96
update the source example related to luminaire source
Aug 5, 2025
359eeb6
refactor the Luminous and Radiant to BaseSource class
Aug 5, 2025
85ae2f1
refactor rayfile source
Aug 6, 2025
30744e7
refactor the test and example using new rayfile source methods
Aug 6, 2025
75cbaea
refactor the surface source class
Aug 6, 2025
a644db0
update the source test and example
Aug 6, 2025
b0ef0db
Merge branch 'main' into refactor/source
pluAtAnsys Aug 6, 2025
0fab2d4
chore: adding changelog file 690.added.md [dependabot-skip]
pyansys-ci-bot Aug 6, 2025
f636777
fix issue and change default mono spectrum value
Aug 6, 2025
da67f35
update other tests based on the new refactor methods from source.py
Aug 6, 2025
fef8ac7
fix visual data issue
Aug 6, 2025
2a5bf45
update other examples related to source refactor methods
Aug 6, 2025
e51350b
fix issue in sensor test and sensor class
Aug 6, 2025
1f7a9f4
fix sensor refactor methods related in prism-example.py
Aug 6, 2025
8f42a9c
fix issue in project.py
Aug 6, 2025
1719bf5
fix example issue
Aug 6, 2025
c7fc8af
fix issue in document example
Aug 6, 2025
4ebbc84
improve code coverage
Aug 6, 2025
94b53f3
issue fix in test
Aug 6, 2025
56dd33d
improve code coverage
Aug 6, 2025
749ea89
improve code coverage
Aug 6, 2025
aaa84d0
Update src/ansys/speos/core/source.py
pluAtAnsys Aug 7, 2025
5426819
Update src/ansys/speos/core/source.py
pluAtAnsys Aug 7, 2025
28ca1dc
Update src/ansys/speos/core/source.py
pluAtAnsys Aug 7, 2025
5767315
Update src/ansys/speos/core/generic/constants.py
pluAtAnsys Aug 7, 2025
06c33ed
Update src/ansys/speos/core/source.py
pluAtAnsys Aug 7, 2025
4e520bc
ci: auto fixes from pre-commit.com hooks.
pre-commit-ci[bot] Aug 7, 2025
10c6a2d
Update src/ansys/speos/core/source.py
pluAtAnsys Aug 7, 2025
3d20f79
fix issue and add exitgeometry sub-class
Aug 7, 2025
13130d0
improve code coverage
Aug 7, 2025
df97791
Merge branch 'main' into refactor/source
pluAtAnsys Aug 31, 2025
c14208f
refactor cheat_sheet_script.qmd content accordingly
Aug 31, 2025
7259117
refactor the intensity type of flux into BaseSource class
Sep 2, 2025
b86d00f
add test reference result from constants
Sep 2, 2025
da7e5f0
refactor the flux type class
Sep 2, 2025
4786dba
refactor the flux class and corresponding unittests
Sep 4, 2025
8512e07
chore: adding changelog file 690.added.md [dependabot-skip]
pyansys-ci-bot Sep 4, 2025
58e6075
clean the comments
Sep 4, 2025
033a969
Merge remote-tracking branch 'origin/refactor/source' into refactor/s…
Sep 4, 2025
985ab5c
Merge branch 'main' into refactor/source
pluAtAnsys Sep 4, 2025
b7c4ad4
correct example document
Sep 4, 2025
e281307
refactor the flux properties
Sep 6, 2025
49979bc
refactor the example
Sep 6, 2025
339887d
Merge branch 'main' into refactor/source
pluAtAnsys Sep 11, 2025
8903fa0
constants.py default values
Sep 15, 2025
ae3f817
Merge branch 'main' into refactor/source
pluAtAnsys Sep 15, 2025
e522762
refactor the constant class
Sep 15, 2025
c1b392a
Merge branch 'main' into refactor/source
pluAtAnsys Sep 15, 2025
c29c6f1
fix mutable variable
Sep 15, 2025
bed1f71
Merge remote-tracking branch 'origin/refactor/source' into refactor/s…
Sep 15, 2025
06294a6
refactor the constants.py to address default parameters
Sep 16, 2025
fec559e
Merge branch 'main' into refactor/source
pluAtAnsys Sep 18, 2025
0b3bf19
apply the constants.py discussion
Sep 18, 2025
8caa372
Merge branch 'main' into refactor/source
pluAtAnsys Sep 18, 2025
11a453e
Merge branch 'main' into refactor/source
pluAtAnsys Sep 23, 2025
d99d8b1
change to constants.py ORIGIN
Sep 23, 2025
fee28f8
Merge remote-tracking branch 'origin/refactor/source' into refactor/s…
Sep 23, 2025
823781c
add comparison with value from default parameter instance
Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/690.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor source class
25 changes: 13 additions & 12 deletions doc/source/cheat_sheet/cheat_sheet_script.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ s_source = project.create_source(name='Surface.1', feature_type=SourceSurface)
# Choose one way to set source power
# for any conflicting property the last set property counts
s_source.set_flux_from_intensity_file()
s_source.set_flux_luminous(683)
s_source.set_flux_radiant(1)
s_source.set_flux_luminous_intensity(5)
s_source.set_exitance_constant(
[(core.GeoRef.from_native_link(
'TheBodyB/TheFaceF'), False)])
s_source.set_flux_luminous().value = 683
s_source.set_flux_radiant().value = 1
s_source.set_flux_luminous_intensity().value = 5
s_source.set_exitance_constant().geometries = [
(core.GeoRef.from_native_link(
'TheBodyB/TheFaceF'), False)
]
s_int = s_source.set_intensity()
s_int.set_cos(1,120)
s_source.set_spectrum()
Expand All @@ -150,13 +151,13 @@ r_source.set_ray_file_uri('path/ray.ray')
# Choose one way to set source power
# for any conflicting property the last set property counts
r_source.set_flux_from_ray_file()
r_source.set_flux_luminous(683)
r_source.set_flux_radiant(1)
r_source.set_flux_luminous().value = 683
r_source.set_flux_radiant().value = 1
r_source.set_spectrum_from_ray_file()
r_source.set_exit_geometries(
[core.GeoRef.from_native_link(
'TheBodyB/TheFaceF')])
r_source.set_axis_system([0,0,0,1,0,0,0,1,0,0,0,1])
r_source.set_exit_geometries().geometries = [
core.GeoRef.from_native_link('TheBodyB/TheFaceF'),
]
r_source.axis_system = [0,0,0,1,0,0,0,1,0,0,0,1]
r_source.commit()
```

Expand Down
4 changes: 3 additions & 1 deletion examples/core/prism-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@

irr_features = p.find(name=".*", name_regex=True, feature_type=SensorIrradiance)
irr = irr_features[0]
irr.set_type_spectral().set_wavelengths_range().set_start(500).set_end(600).set_sampling(11)
irr.set_type_spectral().set_wavelengths_range().start = 500
irr.set_type_spectral().set_wavelengths_range().end = 600
irr.set_type_spectral().set_wavelengths_range().sampling = 11
irr.commit()

# Create and add a new sensor, e.g. 3d irradiance sensor
Expand Down
4 changes: 2 additions & 2 deletions examples/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
# #### Source

source1 = p.create_source(name="Source.1", feature_type=SourceLuminaire)
source1.set_intensity_file_uri(uri=str(assets_data_path / "IES_C_DETECTOR.ies"))
source1.intensity_file_uri = assets_data_path / "IES_C_DETECTOR.ies"
source1.commit()


Expand Down Expand Up @@ -193,7 +193,7 @@

# modify the surface source, e.g. surface source wavelength:

src.set_spectrum().set_monochromatic(wavelength=550)
src.set_spectrum().set_monochromatic().wavelength = 550
src.commit()


Expand Down
2 changes: 1 addition & 1 deletion examples/core/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
# ### Prepare a surface source

source1 = p.create_source(name=SOURCE_NAME)
source1.set_exitance_constant(geometries=[(face_1, True)])
source1.set_exitance_constant().geometries = [(face_1, True)]
# define a spectrum which is not monochromatic so it can be used in both direct and inverse
# simulation
source1.set_spectrum().set_blackbody()
Expand Down
32 changes: 16 additions & 16 deletions examples/core/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def create_face(body):

intensity_file_path = str(assets_data_path / IES)
source1 = p.create_source(name="Luminaire.1", feature_type=SourceLuminaire) # type luminaire
source1.set_intensity_file_uri(uri=intensity_file_path)
source1.intensity_file_uri = intensity_file_path
print(source1)

# **Push it to the server.**
Expand All @@ -114,10 +114,11 @@ def create_face(body):

intensity_file_path = str(assets_data_path / IES)
source2 = p.create_source(name="Luminaire.2", feature_type=SourceLuminaire)
source2.set_intensity_file_uri(uri=intensity_file_path)
source2.set_flux_radiant() # select flux radiant with default value
source2.intensity_file_uri = intensity_file_path
source2.set_flux().set_radiant()
source2.set_flux().value = 1.0 # select flux radiant
# choose the source location [Origin, Xvector, Yvector, Zvector]
source2.set_axis_system(axis_system=[20, 50, 10, 1, 0, 0, 0, 1, 0, 0, 0, 1])
source2.axis_system = [20, 50, 10, 1, 0, 0, 0, 1, 0, 0, 0, 1]
source2.set_spectrum().set_blackbody() # choose blackbody with default value for the spectrum
source2.commit() # Push to the server
print(source2)
Expand All @@ -140,8 +141,9 @@ def create_face(body):
# > changes.
# > If you don't, you will still only watch what is committed on the server.

source1.set_flux_radiant(value=1.2) # modify radiant flux value
source1.set_axis_system(axis_system=[17, 10, 10, 1, 0, 0, 0, 1, 0, 0, 0, 1]) # modify axis system
source1.set_flux().set_radiant()
source1.set_flux().value = 1.2 # modify radiant flux value
source1.axis_system = [17, 10, 10, 1, 0, 0, 0, 1, 0, 0, 0, 1] # modify axis system
source1.set_spectrum().set_halogen() # modify spectrum by choosing halogen
source1.commit() # Push changes to the server
print(source1)
Expand All @@ -150,7 +152,7 @@ def create_face(body):
#
# Possibility to reset local values from the one available in the server.

source1.set_flux_luminous() # modify to luminous flux BUT no commit
source1.set_flux().set_luminous().value = 683.0 # modify to luminous flux BUT no commit
source1.reset()
# reset -> this will apply the server value to the local value the local value will be back to
# halogen
Expand Down Expand Up @@ -178,13 +180,13 @@ def create_face(body):
ray_file_path = str(assets_data_path / "Rays.ray")

source3 = p.create_source(name="Ray-file.1", feature_type=SourceRayFile) # type ray file
source3.set_ray_file_uri(uri=ray_file_path)
source3.ray_file_uri = ray_file_path
source3.commit()
print(source3)
# -

# +
source3.set_flux_luminous()
source3.set_flux().set_luminous()
source3.commit()
print(source3)
# -
Expand All @@ -198,18 +200,16 @@ def create_face(body):
# +
create_helper_geometries(p)
source4 = p.create_source(name="Surface.1", feature_type=SourceSurface)
source4.set_exitance_constant(
geometries=[
(GeoRef.from_native_link("TheBodyB/TheFaceF"), False),
(GeoRef.from_native_link("TheBodyC/TheFaceF"), True),
]
)
source4.set_exitance_constant().geometries = [
(GeoRef.from_native_link("TheBodyB/TheFaceF"), False),
(GeoRef.from_native_link("TheBodyC/TheFaceF"), True),
]
source4.commit()
print(source4)
# -

# +
source4.set_flux_luminous_intensity()
source4.set_flux().set_luminous_intensity()
source4.set_intensity().set_gaussian().set_axis_system(
axis_system=[10, 50, 20, 1, 0, 0, 0, 1, 0, 0, 0, 1]
)
Expand Down
7 changes: 3 additions & 4 deletions examples/workflow/combine-speos.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@

# +
src = p.create_source(name="Luminaire.1", feature_type=SourceLuminaire)
src.set_intensity_file_uri(
uri=str(assets_data_path / "IES_C_DETECTOR.ies")
).set_spectrum().set_daylightfluorescent()
src.set_axis_system([0, 10000, 50000, 1, 0, 0, 0, 1, 0, 0, 0, 1])
src.intensity_file_uri = assets_data_path / "IES_C_DETECTOR.ies"
src.set_spectrum().set_daylightfluorescent()
src.axis_system = [0, 10000, 50000, 1, 0, 0, 0, 1, 0, 0, 0, 1]

src.commit()
# -
Expand Down
99 changes: 99 additions & 0 deletions src/ansys/speos/core/generic/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

"""Collection of all constants used in pySpeos."""

from dataclasses import dataclass, field
import os
from typing import Union

DEFAULT_HOST: str = "localhost"
"""Default host used by Speos RPC server and client """
Expand All @@ -38,3 +40,100 @@
"""Maximum message Size accepted by grpc channel,
By default, 4194304.
"""
ORIGIN = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]
"""Global Origin"""


class SPECTRUM:
"""Constant class for Spectrum."""

class MONOCHROMATIC:
"""Constant class for Monochromatic."""

WAVELENGTH = 555

class BLACKBODY:
"""Constant class for BlackBody."""

TEMPERATURE = 2856


class SOURCE:
"""Constant class for Sources."""

class LUMINOUS:
"""Constant class for Luminous."""

VALUE = 683

class RADIANT:
"""Constant class for Radiant."""

VALUE = 1

class INTENSITY:
"""Constant class for Intensity."""

VALUE = 5


@dataclass(frozen=True)
class FluxLuminous:
"""Constant class for Luminous type Flux."""

value: float = 683


@dataclass(frozen=True)
class FluxRadiant:
"""Constant class for Radiant type Flux."""

value: float = 1


@dataclass(frozen=True)
class SourceRayfileParamters:
"""Constant class for SourceRayfileParamters."""

flux_from_ray_file: bool = True
flux_luminous: Union[bool, FluxLuminous] = FluxLuminous()
flux_radiant: Union[bool, FluxRadiant] = False
axis_system: list[float] = field(default_factory=lambda: [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1])


class SENSOR:
"""Constant class for Sensors."""

class WAVELENGTHSRANGE:
"""Wavelength constants."""

START = 400
"""Wavelength start value."""
END = 700
"""Wavelength end value."""
SAMPLING = 13
"""Wavelength sampling."""

class DIMENSIONS:
"""Dimension Constants."""

X_START = -50
"""Lower bound x axis."""
X_END = 50
"""Upper bound x axis."""
X_SAMPLING = 100
"""Sampling x axis."""
Y_START = -50
"""Lower bound y axis."""
Y_END = 50
"""Upper bound y axis."""
Y_SAMPLING = 100
"""Sampling y axis."""

class LAYERTYPES:
"""Layer Separation constants."""

MAXIMUM_NB_OF_SEQUENCE = 10
"""Number of sequences stored in sensor."""
INCIDENCE_SAMPLING = 9
"""Number of incidence sampling stored in sensor"""
Loading
Loading