Skip to content

Commit

Permalink
Pdf report class (#2860)
Browse files Browse the repository at this point in the history
* add new class to create pdf reports.

* Added unit tests

* Added example

* Added example

* Revert "Added example"

This reverts commit 70851ac.

* Added example

* Net6_refactoring

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Back to .net framework

* Updated to .netcore

* Updated to .netcore

* Updated to .netcore

* Updated to .netcore

* Updated to .netcore

* Updated to .netcore

* Updated to .netcore

* Updated to .netcore

* Updated to .netcore

* Updated to .netcore

---------

Co-authored-by: maxcapodi78 <Shark78>
Co-authored-by: svandenb <[email protected]>
  • Loading branch information
maxcapodi78 and svandenb-dev authored Apr 27, 2023
1 parent ea05a16 commit c57b881
Show file tree
Hide file tree
Showing 41 changed files with 93,073 additions and 41,499 deletions.
Binary file added _unittest/example_models/Coax_HFSS.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions _unittest/test_01_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import os

from _unittest.conftest import desktop_version
from _unittest.conftest import local_path
from _unittest.conftest import scratch_path

from pyaedt import pyaedt_path
from pyaedt.generic.pdf import AnsysReport

try:
import pytest # noqa: F401
except ImportError:
import _unittest_ironpython.conf_unittest as pytest # noqa: F401

tol = 1e-12


class TestClass(object):
def setup_class(self):
pass

def teardown_class(self):
pass

def test_create_pdf(self):
template_path = os.path.join(pyaedt_path, "dlls", "PDFReport", "AnsysTemplate.json")
report = AnsysReport(project_name="Coaxial", design_name="Design1", tempplate_json_file=template_path)
report.aedt_version = desktop_version
assert "AnsysTemplate" in report.template_name
report.template_name = "AnsysTemplate"
assert report.project_name == "Coaxial"
report.project_name = "Coaxial1"
assert report.project_name == "Coaxial1"
assert report.design_name == "Design1"
report.design_name = "Design2"
assert report.design_name == "Design2"
report.create()
report.add_section()
report.add_chapter("Chapter 1")
report.add_sub_chapter("C1")
report.add_text("ciao")
report.add_text("ciao2", True, True)
report.add_empty_line(2)
report.add_page_break()
report.add_image(os.path.join(local_path, "example_models", "Coax_HFSS.jpg"), "Coaxial Cable")
report.add_section("L")
report.add_table("MyTable", [["x", "y"], ["0", "1"], ["2", "3"], ["10", "20"]])
report.add_section()
report.add_chart([0, 1, 2, 3, 4, 5], [10, 20, 4, 30, 40, 12], "Freq", "Val", "MyTable")
report.add_toc()
assert os.path.exists(report.save_pdf(scratch_path, "my_firstpdf.pdf"))
35 changes: 34 additions & 1 deletion examples/06-Multiphysics/Hfss_Icepak_Coupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import os
import pyaedt
from pyaedt.generic.pdf import AnsysReport

###############################################################################
# Set non-graphical mode
Expand Down Expand Up @@ -328,7 +329,39 @@
cxt = ["Domain:=", "Sweep"]
families = ["Freq:=", ["All"]]
my_data = aedtapp.post.get_solution_data(expressions=trace_names)
my_data.plot(trace_names, "db20", xlabel="Frequency (Ghz)", ylabel="SParameters(dB)", title="Scattering Chart")
my_data.plot(trace_names, "db20",
xlabel="Frequency (Ghz)",
ylabel="SParameters(dB)",
title="Scattering Chart",
snapshot_path=os.path.join(results_folder, "Touchstone_from_matplotlib.jpg"))

################################################################################
# Generate pdf report
# ~~~~~~~~~~~~~~~~~~~
# Generate a pdf report with output of simultion.
report = AnsysReport(project_name=aedtapp.project_name, design_name=aedtapp.design_name,version=desktopVersion)
report.create()


report.add_section()
report.add_chapter("Hfss Results")
report.add_sub_chapter("Field Plot")
report.add_text("This section contains Field plots of Hfss Coaxial.")
report.add_image(os.path.join(results_folder, plot1.name+".jpg"), "Coaxial Cable")
report.add_page_break()
report.add_sub_chapter("S Parameters")
report.add_chart(my_data.intrinsics["Freq"], my_data.data_db20(), "Freq", trace_names[0], "S-Parameters")
report.add_image(os.path.join(results_folder, "Touchstone_from_matplotlib.jpg"), "Touchstone from Matplotlib")
report.add_section()
report.add_chapter("Icepak Results")
report.add_sub_chapter("Temperature Plot")
report.add_text("This section contains Multiphysics temperature plot.")

report.add_image(os.path.join(results_folder, plot5.name+".jpg"), "Coaxial Cable Temperatures")
report.add_toc()
report.save_pdf(results_folder, "AEDT_Results.pdf")



################################################################################
# Close project and release AEDT
Expand Down
Loading

0 comments on commit c57b881

Please sign in to comment.