Skip to content

add symbolic bosons and spins#81

Open
cvsvensson wants to merge 30 commits intomainfrom
support_different_commutative_symbols
Open

add symbolic bosons and spins#81
cvsvensson wants to merge 30 commits intomainfrom
support_different_commutative_symbols

Conversation

@cvsvensson
Copy link
Owner

No description provided.

@github-actions
Copy link

github-actions bot commented Mar 11, 2026

Benchmark Results (Julia v1)

Time benchmarks
main e442839... main / e442839...
embed 2.62 ± 0.38 ms 2.63 ± 0.11 ms 0.996 ± 0.15
generate_states/big_int 7.81 ± 2.1 ms 7.65 ± 2.2 ms 1.02 ± 0.4
generate_states/int 1.06 ± 0.01 ms 1.06 ± 0.013 ms 1 ± 0.016
hilbert_space 0.0887 ± 0.0057 ms 0.0858 ± 0.0078 ms 1.03 ± 0.12
matrix_representation/bdg 0.957 ± 0.04 ms 0.919 ± 0.037 ms 1.04 ± 0.06
matrix_representation/free_fermion 0.385 ± 0.017 ms 0.44 ± 0.017 ms 0.876 ± 0.051
matrix_representation/standard 2.13 ± 0.072 ms 2.07 ± 0.079 ms 1.03 ± 0.052
partial_trace/map 0.0466 ± 0.0044 s 0.0438 ± 0.0038 s 1.07 ± 0.14
partial_trace/standard 2.07 ± 0.011 ms 2.08 ± 0.02 ms 0.997 ± 0.011
partial_trace_algorithms/default=FullAlg/Sparse space/Dense/FullAlg 13.6 ± 0.07 ms 13.6 ± 0.077 ms 1 ± 0.0077
partial_trace_algorithms/default=FullAlg/Sparse space/Dense/SubAlg 0.0322 ± 7.5e-05 s 0.0322 ± 8.2e-05 s 0.999 ± 0.0035
partial_trace_algorithms/default=FullAlg/Sparse space/Sparse/FullAlg 0.182 ± 0.0082 ms 0.182 ± 0.0089 ms 1 ± 0.067
partial_trace_algorithms/default=FullAlg/Sparse space/Sparse/SubAlg 0.0327 ± 5.6e-05 s 0.0327 ± 6.5e-05 s 1 ± 0.0026
partial_trace_algorithms/default=SubAlg/Full space/Dense/FullAlg 25.6 ± 0.067 ms 25.2 ± 0.051 ms 1.02 ± 0.0034
partial_trace_algorithms/default=SubAlg/Full space/Dense/SubAlg 0.112 ± 0.00077 ms 0.112 ± 0.00063 ms 0.993 ± 0.0089
partial_trace_algorithms/default=SubAlg/Full space/Sparse/FullAlg 0.286 ± 0.0099 ms 0.284 ± 0.0097 ms 1.01 ± 0.049
partial_trace_algorithms/default=SubAlg/Full space/Sparse/SubAlg 0.137 ± 0.00062 ms 0.137 ± 0.0006 ms 1 ± 0.0063
symbolic/deep_product 5.81 ± 0.13 ms 8.02 ± 0.16 ms 0.724 ± 0.021
symbolic/sum 0.198 ± 0.01 ms 0.363 ± 0.014 ms 0.546 ± 0.036
symbolic/sum_square 5.62 ± 0.11 ms 8.67 ± 0.25 ms 0.649 ± 0.022
time_to_load 0.559 ± 0.0042 s 0.578 ± 0.0018 s 0.966 ± 0.0079
Memory benchmarks
main e442839... main / e442839...
embed 0.183 k allocs: 3.5 MB 0.186 k allocs: 3.51 MB 0.999
generate_states/big_int 0.339 M allocs: 8.3 MB 0.339 M allocs: 8.3 MB 1
generate_states/int 0.153 k allocs: 16.4 kB 0.153 k allocs: 16.4 kB 1
hilbert_space 0.082 k allocs: 0.254 MB 0.082 k allocs: 0.254 MB 1
matrix_representation/bdg 5.26 k allocs: 2.19 MB 5.26 k allocs: 2.16 MB 1.01
matrix_representation/free_fermion 3.04 k allocs: 0.41 MB 3.04 k allocs: 0.422 MB 0.971
matrix_representation/standard 0.216 k allocs: 4.06 MB 0.509 k allocs: 4.67 MB 0.871
partial_trace/map 0.198 k allocs: 0.254 GB 0.203 k allocs: 0.254 GB 1
partial_trace/standard 0.121 k allocs: 0.126 MB 0.126 k allocs: 0.13 MB 0.969
partial_trace_algorithms/default=FullAlg/Sparse space/Dense/FullAlg 0.105 k allocs: 0.0828 MB 0.107 k allocs: 0.0845 MB 0.979
partial_trace_algorithms/default=FullAlg/Sparse space/Dense/SubAlg 0.125 k allocs: 0.0854 MB 0.127 k allocs: 0.0871 MB 0.98
partial_trace_algorithms/default=FullAlg/Sparse space/Sparse/FullAlg 0.116 k allocs: 0.14 MB 0.118 k allocs: 0.141 MB 0.988
partial_trace_algorithms/default=FullAlg/Sparse space/Sparse/SubAlg 0.126 k allocs: 0.0854 MB 0.128 k allocs: 0.0872 MB 0.98
partial_trace_algorithms/default=SubAlg/Full space/Dense/FullAlg 0.037 k allocs: 2.25 kB 0.037 k allocs: 2.25 kB 1
partial_trace_algorithms/default=SubAlg/Full space/Dense/SubAlg 0.057 k allocs: 5 kB 0.057 k allocs: 5 kB 1
partial_trace_algorithms/default=SubAlg/Full space/Sparse/FullAlg 0.047 k allocs: 0.323 MB 0.047 k allocs: 0.323 MB 1
partial_trace_algorithms/default=SubAlg/Full space/Sparse/SubAlg 0.057 k allocs: 5 kB 0.057 k allocs: 5 kB 1
symbolic/deep_product 0.133 M allocs: 6.26 MB 0.151 M allocs: 6.66 MB 0.94
symbolic/sum 5.04 k allocs: 0.521 MB 5.64 k allocs: 0.539 MB 0.966
symbolic/sum_square 0.139 M allocs: 6.81 MB 0.19 M allocs: 7.86 MB 0.867
time_to_load 0.145 k allocs: 11 kB 0.145 k allocs: 11 kB 1

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 84.90099% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.63%. Comparing base (45f2678) to head (e442839).

Files with missing lines Patch % Lines
src/symbolics/muladd.jl 87.12% 17 Missing ⚠️
src/majoranas.jl 73.46% 13 Missing ⚠️
src/symbolics/symbolic_fermions.jl 37.50% 10 Missing ⚠️
src/operators.jl 35.71% 9 Missing ⚠️
src/bosons.jl 88.88% 7 Missing ⚠️
src/spin.jl 94.80% 4 Missing ⚠️
src/fixednumberfock.jl 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #81      +/-   ##
==========================================
- Coverage   86.17%   85.63%   -0.54%     
==========================================
  Files          20       20              
  Lines        2192     2479     +287     
==========================================
+ Hits         1889     2123     +234     
- Misses        303      356      +53     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cvsvensson and others added 16 commits March 11, 2026 10:11
* reorganize product spaces and relation between spaces and symbols

* many things

* add BlockHilbertSpace, add support for combine_states and split_states to return a list of states

* Making changes to fix tests one by one

* mainly work on symmetries

* fixing tests, defining printing, moving code around

* fix tests, handle nested wrappers, add basis_transformation, don't let subregion change the order of states

* fix tests, rename atomic_group to symbolic_group, use NCMul in apply_local_operators

* remove files, simplify floquet, update test manifest

* update examples

* tet open system
@williamesamuelson
Copy link
Collaborator

I’m wondering if it would make sense to introduce a SymbolicBosonBasis (similar to fermions) and let BosonSym carry both the basis and an optional label, so we can support both single-mode bosons (a) and indexed bosons (b[1]). I guess then one creates single-mode bosons by @boson and indexed ones by @bosons.

@cvsvensson
Copy link
Owner Author

The reason I did it this way is to mirror the behaviour of the hilbert spaces, where fermionic spaces can combine into a cluster. For bosons and spins the spaces will not combine, so I let the symbolic operators also be completely independent. However, one can add a convenience macro, as I have done for spins. There one can do

@spin S 
# or 
@spins S 1:4

where the latter defines S as a vector of symbolic spins so you can index it similarly to the fermion field. Maybe it should be a dictionary instead, so that @spins S labels defines S so that it can be indexed by the labels.

I don't see a good reason to define bosonic and spin fields right now, but if we add clusters of bosons and spins, it would make sense.

@williamesamuelson
Copy link
Collaborator

Can I add more stuff here, or do you want to merge first?

@cvsvensson
Copy link
Owner Author

Go ahead and add stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants