def start_RepTate(argv):
    """
    Main RepTate application. 
    
    :param list argv: Command line parameters passed to Reptate
    """
    loglevel = logging.DEBUG
    GUI = True
    QApplication.setStyle("Fusion")  # comment that line for a native look
    # for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    # app = QApplication(sys.argv)

    # FOR DEBUGGING PURPOSES: Set Single or MultiThread (default)
    CmdBase.calcmode = CalcMode.singlethread

    ex = QApplicationManager(loglevel=loglevel)
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")

    ########################################################
    # THE FOLLOWING LINES ARE FOR TESTING A PARTICULAR CASE
    # Open a particular application
    ex.handle_new_app("React")

    #####################
    # Open a Dataset
    ex.applications["React1"].new_tables_from_files([
        "data%sReact%sout1.reac" % ((os.sep, ) * 2),
    ])
    # Open a theory
    ex.applications["React1"].datasets["Set1"].new_theory("BOB Architecture")

    ex.show()

    sys.exit(app.exec_())
Esempio n. 2
0
def start_RepTate(argv):
    """
    Main RepTate application. 
    
    :param list argv: Command line parameters passed to Reptate
    """
    loglevel = logging.DEBUG
    GUI = True
    QApplication.setStyle("Fusion")  # comment that line for a native look
    # for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    app = QApplication(sys.argv)

    # FOR DEBUGGING PURPOSES: Set Single or MultiThread (default)
    CmdBase.calcmode = CalcMode.singlethread

    ex = QApplicationManager(loglevel=loglevel)
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")

    ex.show()

    ########################################################
    # THE FOLLOWING LINES ARE FOR TESTING A PARTICULAR CASE
    # Open a particular application
    ex.handle_new_app("TTS")

    # Open a Dataset
    pi_dir = "data%sPI_LINEAR%sosc%s" % ((os.sep, ) * 3)
    ex.applications["TTS1"].new_tables_from_files([
        pi_dir + "PI223k-14c_-45C_FS2_PP10.osc",
        pi_dir + "PI223k-14c_-40C_FS_PP10.osc",
        pi_dir + "PI223k-14c_-30C_FS_PP10.osc",
        pi_dir + "PI223k-14_-10C_FS_PP10.osc",
        pi_dir + "PI223k-14c_-20C_FS_PP10.osc",
        pi_dir + "PI223k-14b_0C_FS4_PP10.osc",
        pi_dir + "PI223k-14_10C_FS_PP10.osc",
        pi_dir + "PI223k-14b_25C_FS3_PP10.osc",
        pi_dir + "PI223k-14_25C_FS3_PP10.osc",
        pi_dir + "PI223k-14c_30C_FS3_PP10.osc",
        pi_dir + "PI223k-14_40C_FS_PP10.osc",
        pi_dir + "PI223k-14_50C_FS_PP10.osc",
    ])

    # Open a theory
    ex.applications["TTS1"].datasets["Set1"].new_theory("Automatic TTS Shift")
    # Minimize the theory
    ex.applications["TTS1"].datasets["Set1"].handle_actionMinimize_Error()
    # Open a theory
    ex.applications["TTS1"].datasets["Set1"].new_theory("WLF Shift")
    # Minimize the theory
    ex.applications["TTS1"].datasets["Set1"].handle_actionMinimize_Error()

    sys.exit(app.exec_())
Esempio n. 3
0
def start_RepTate(argv):
    """
    Main RepTate application. 
    
    :param list argv: Command line parameters passed to Reptate
    """
    loglevel = logging.DEBUG
    GUI = True
    QApplication.setStyle("Fusion")  # comment that line for a native look
    # for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    app = QApplication(sys.argv)

    # FOR DEBUGGING PURPOSES: Set Single or MultiThread (default)
    CmdBase.calcmode = CalcMode.singlethread

    ex = QApplicationManager(loglevel=loglevel)
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")

    ex.show()

    ########################################################
    # THE FOLLOWING LINES ARE FOR TESTING A PARTICULAR CASE
    # Open a particular application
    ex.handle_new_app("MWD")

    #####################
    # Open a Dataset
    gt_dir = "data%sMWD%s" % ((os.sep, ) * 2)
    ex.applications["MWD1"].new_tables_from_files([
        gt_dir + "Munstedt_PSIII.gpc",
    ])
    # Open a theory
    ex.applications["MWD1"].datasets["Set1"].new_theory("Discretize MWD")
    ex.applications["MWD1"].datasets["Set1"].new_theory("LogNormal")
    ex.applications["MWD1"].datasets["Set1"].new_theory("GEX")

    sys.exit(app.exec_())

    ex.handle_new_app("MWD")

    # THE TEST FAILS FOR THE CODE BELOW... STRANGE!
    ex.applications["MWD2"].new_tables_from_files([
        gt_dir + "Munstedt_PSIV.gpc",
    ])
    # Open a theory
    ex.applications["MWD2"].datasets["Set1"].new_theory("Discretize MWD")
    ex.applications["MWD2"].datasets["Set1"].new_theory("LogNormal")
    ex.applications["MWD2"].datasets["Set1"].new_theory("GEX")

    sys.exit(app.exec_())
def start_RepTate(argv):
    """
    Main RepTate application. 
    
    :param list argv: Command line parameters passed to Reptate
    """
    loglevel = logging.DEBUG
    GUI = True
    QApplication.setStyle("Fusion")  # comment that line for a native look
    # for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    app = QApplication(sys.argv)

    # FOR DEBUGGING PURPOSES: Set Single or MultiThread (default)
    CmdBase.calcmode = CalcMode.singlethread

    ex = QApplicationManager(loglevel=loglevel)
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")

    ex.show()

    ########################################################
    # THE FOLLOWING LINES ARE FOR TESTING A PARTICULAR CASE
    # Open a particular application
    ex.handle_new_app("Gt")

    #####################
    # TEST MaxwellModesTime
    # Open a Dataset
    gt_dir = "data%sGt%s" % ((os.sep, ) * 2)
    ex.applications["Gt1"].new_tables_from_files([
        gt_dir + "C0224_NVT_450K_1atm.gt",
    ])
    # Open a theory
    ex.applications["Gt1"].datasets["Set1"].new_theory("Maxwell Modes")
    # Minimize the theory
    ex.applications["Gt1"].datasets["Set1"].handle_actionMinimize_Error()

    ex.applications["Gt1"].datasets["Set1"].new_theory("Rouse")
    # # Minimize the theory
    ex.applications["Gt1"].datasets["Set1"].handle_actionMinimize_Error()

    sys.exit(app.exec_())
def start_RepTate(argv):
    """
    Main RepTate application. 
    
    :param list argv: Command line parameters passed to Reptate
    """
    loglevel = logging.DEBUG
    GUI = True
    QApplication.setStyle("Fusion")  # comment that line for a native look
    # for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    app = QApplication(sys.argv)

    # FOR DEBUGGING PURPOSES: Set Single or MultiThread (default)
    CmdBase.calcmode = CalcMode.singlethread

    ex = QApplicationManager(loglevel=loglevel)
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")

    ex.show()

    ########################################################
    # THE FOLLOWING LINES ARE FOR TESTING A PARTICULAR CASE
    # Open a particular application
    ex.handle_new_app("LVE")

    #####################
    # TEST Likhtman-McLeish
    # Open a Dataset
    pi_dir = "data%sPI_LINEAR%s" % ((os.sep,) * 2)
    ex.applications["LVE1"].new_tables_from_files(
        [
            pi_dir + "PI_13.5k_T-35.tts",
            pi_dir + "PI_23.4k_T-35.tts",
            pi_dir + "PI_33.6k_T-35.tts",
            pi_dir + "PI_94.9k_T-35.tts",
            pi_dir + "PI_225.9k_T-35.tts",
            pi_dir + "PI_483.1k_T-35.tts",
            pi_dir + "PI_634.5k_T-35.tts",
            pi_dir + "PI_1131k_T-35.tts",
        ]
    )
    # Open a theory
    ex.applications["LVE1"].datasets["Set1"].new_theory("Likhtman-McLeish")
    # Minimize the theory
    ex.applications["LVE1"].datasets["Set1"].handle_actionMinimize_Error()

    # Open a theory
    ex.applications["LVE1"].datasets["Set1"].new_theory("Rouse")
    # Minimize the theory
    ex.applications["LVE1"].datasets["Set1"].handle_actionMinimize_Error()

    #####################
    # TEST Carreau-Yasuda
    # Open a Dataset
    ex.handle_new_app("LVE")
    ex.applications["LVE2"].new_tables_from_files(
        [pi_dir + "PI_483.1k_T-35.tts",]
    )
    # Switch the view
    ex.applications["LVE2"].view_switch("logetastar")
    # Open a theory
    ex.applications["LVE2"].datasets["Set1"].new_theory("Carreau-Yasuda")
    # Minimize the theory
    ex.applications["LVE2"].datasets["Set1"].handle_actionMinimize_Error()

    # Open a theory
    ex.applications["LVE2"].datasets["Set1"].new_theory("Maxwell Modes")
    # Minimize the theory
    ex.applications["LVE2"].datasets["Set1"].handle_actionMinimize_Error()

    #####################
    # TEST DTD
    # Open a Dataset
    ex.handle_new_app("LVE")
    pi_dir = "data%sPI_STAR%s" % ((os.sep,) * 2)
    ex.applications["LVE3"].new_tables_from_files(
        [pi_dir + "S6Z8.1T40.tts", pi_dir + "S6Z12T40.tts", pi_dir + "S6Z16T40.tts",]
    )

    ex.applications["LVE3"].datasets["Set1"].new_theory("DTD Stars")
    ex.applications["LVE3"].datasets["Set1"].handle_actionMinimize_Error()

    sys.exit(app.exec_())
Esempio n. 6
0
def start_RepTate(argv):
    """
    Main RepTate application.

    :param list argv: Command line parameters passed to Reptate
    """
    GUI = True

    parser = argparse.ArgumentParser(
        description=
        "RepTate: Rheology of Entangled Polymers: Toolkit for the Analysis of Theory and Experiment.",
        epilog=
        "(c) Jorge Ramirez ([email protected], UPM), Victor Boudara (U. Leeds) (2017-2020)",
    )
    parser.add_argument("-d",
                        "--dpi",
                        help="High DPI support on Windows",
                        action="store_true")
    parser.add_argument("-l",
                        "--tool",
                        help="Open the tool L (if available)",
                        default="",
                        metavar="L")
    parser.add_argument(
        "-s",
        "--single",
        help="Run Reptate as a single thread application",
        action="store_true",
    )
    parser.add_argument(
        "-t",
        "--theory",
        help="Open the theory T (if available)",
        default="",
        metavar="T",
    )
    parser.add_argument("-v",
                        "--verbose",
                        help="Write debug information to stdout",
                        action="store_true")
    parser.add_argument("-V",
                        "--version",
                        help="Print RepTate version and exit",
                        action="store_true")
    parser.add_argument("finlist", nargs="*")

    args = parser.parse_args(args=argv)

    # Get files from command line
    dictfiles = get_argument_files(args.finlist)

    if args.version:
        print(QApplicationManager.intro)
        sys.exit()

    if args.verbose:
        loglevel = logging.DEBUG
    else:
        loglevel = logging.INFO

    QApplication.setStyle("Fusion")  # comment that line for a native look
    # for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    if args.dpi or sys.platform == "darwin":
        os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
        QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
        QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
        QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)

    app = QApplication(sys.argv)
    app.setApplicationName("RepTate")

    if args.dpi and sys.platform == "win32":
        #os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
        import matplotlib
        #matplotlib.pyplot.matplotlib.rcParams['figure.dpi'] = int (np.round(app.desktop().physicalDpiX()/10))
        matplotlib.pyplot.matplotlib.rcParams['figure.dpi'] = 34
        #matplotlib.pyplot.matplotlib.rcParams['figure.dpi'] = app.desktop().physicalDpiX()/4

    splash = SplashScreen()
    splash.show()

    ex = QApplicationManager(loglevel=loglevel)
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")
    # splash.showMessage("Loading RepTate...")

    splash.finish(ex)

    # Handle files & open apps accordingly
    CmdBase.calcmode = (
        CalcMode.singlethread
    )  # avoid troubles when loading multiple apps/files/theories
    d = {
        ex.extension: ex.appname
        for ex in list(ex.available_applications.values())
    }
    toolopen = False
    for k in dictfiles.keys():
        if k == "rept":
            ex.open_project(dictfiles[k][0])
        elif np.any([k == key for key in d.keys()]):
            # exact match
            ex.handle_new_app(d[k])
            appname = "%s%d" % (d[k], ex.application_counter)
            ex.applications[appname].new_tables_from_files(dictfiles[k])
            if args.theory in list(ex.applications[appname].theories.keys()):
                ex.applications[appname].datasets["Set1"].new_theory(
                    args.theory)
            if args.tool in (
                    list(ex.applications[appname].availabletools.keys()) +
                    list(ex.applications[appname].extratools.keys())):
                ex.applications[appname].new_tool(args.tool)
                ex.applications[appname].update_all_ds_plots()
                ex.applications[appname].showDataInspector(True)
                toolopen = True

        elif np.any([k in key
                     for key in d.keys()]):  # works with spaces in extensions
            for key in d.keys():
                if k in key:
                    ex.handle_new_app(d[key])
                    appname = "%s%d" % (d[key], ex.application_counter)
                    ex.applications[appname].new_tables_from_files(
                        dictfiles[k])
                    if args.theory in list(
                            ex.applications[appname].theories.keys()):
                        ex.applications[appname].datasets["Set1"].new_theory(
                            args.theory)
                    if args.tool in (
                            list(
                                ex.applications[appname].availabletools.keys())
                            +
                            list(ex.applications[appname].extratools.keys())):
                        ex.applications[appname].new_tool(args.tool)
                        ex.applications[appname].update_all_ds_plots()
                        ex.applications[appname].showDataInspector(True)
                        toolopen = True
                    break
        else:
            print("File type %s cannot be opened" % k)
    # set the calmode back
    if args.single:
        CmdBase.calcmode = CalcMode.singlethread
    else:
        CmdBase.calcmode = CalcMode.multithread

    ex.showMaximized()
    sys.exit(app.exec_())
Esempio n. 7
0
def start_RepTate(argv):
    """
    Main RepTate application.

    :param list argv: Command line parameters passed to Reptate
    """
    GUI = True

    parser = argparse.ArgumentParser(
        description=
        'RepTate: Rheologhy of Entangled Polymers: Toolkit for the Analysis of Theory and Experiment.',
        epilog=
        '(c) Jorge Ramirez - [email protected] - UPM , Victor Boudara - U. Leeds (2018)'
    )
    parser.add_argument('-d',
                        '--dpi',
                        help='High DPI support on Windows',
                        action='store_true')
    parser.add_argument('-s',
                        '--single',
                        help='Run Reptate as a single thread application',
                        action='store_true')
    parser.add_argument('-t',
                        '--theory',
                        help='Open the given theory (if available)',
                        default='')
    parser.add_argument('-v',
                        '--verbose',
                        help='Write debug information to stdout',
                        action='store_true')
    parser.add_argument('-V',
                        '--version',
                        help='Print RepTate version and exit',
                        action='store_true')
    parser.add_argument('finlist', nargs='*')

    args = parser.parse_args(args=argv)

    # Get files from command line
    dictfiles = get_argument_files(args.finlist)

    if args.version:
        print(QApplicationManager.intro)
        sys.exit()

    if args.verbose:
        loglevel = logging.DEBUG
    else:
        loglevel = logging.INFO

    QApplication.setStyle("Fusion")  #comment that line for a native look
    #for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    if args.dpi:
        os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
        QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
        QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
        QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)

    app = QApplication(sys.argv)
    #if args.dpi:
    #    app.setAttribute(Qt.AA_EnableHighDpiScaling)

    splash = SplashScreen()
    # splash.showMessage("Loading RepTate...\n")
    splash.show()

    ex = QApplicationManager(loglevel=loglevel)
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")
    # splash.showMessage("Loading RepTate...")

    splash.finish(ex)

    # Handle files & open apps accordingly
    CmdBase.calcmode = CalcMode.singlethread  # avoid troubles when loading multiple apps/files/theories
    d = {
        ex.extension: ex.appname
        for ex in list(ex.available_applications.values())
    }
    for k in dictfiles.keys():
        if k == 'rept':
            ex.open_project(dictfiles[k][0])
        elif np.any([k == key for key in d.keys()]):
            # exact match
            ex.handle_new_app(d[k])
            appname = "%s%d" % (d[k], ex.application_counter)
            ex.applications[appname].new_tables_from_files(dictfiles[k])
            if args.theory in list(ex.applications[appname].theories.keys()):
                ex.applications[appname].datasets['Set1'].new_theory(
                    args.theory)

        elif np.any([k in key
                     for key in d.keys()]):  # works with spaces in extensions
            for key in d.keys():
                if k in key:
                    ex.handle_new_app(d[key])
                    appname = "%s%d" % (d[key], ex.application_counter)
                    ex.applications[appname].new_tables_from_files(
                        dictfiles[k])
                    if args.theory in list(
                            ex.applications[appname].theories.keys()):
                        ex.applications[appname].datasets['Set1'].new_theory(
                            args.theory)
                    break
        else:
            print("File type %s cannot be opened" % k)
    # set the calmode back
    if args.single:
        CmdBase.calcmode = CalcMode.singlethread
    else:
        CmdBase.calcmode = CalcMode.multithread

    def my_excepthook(type, value, tb):
        """Catch exceptions and print error message. Open email client to report bug to devlopers"""
        tb_msg = ''
        for e in traceback.format_tb(tb):
            tb_msg += str(e)
        tb_msg += "%s: %s\n" % (type.__name__, str(value))
        #print(tb_msg) # JR: Not needed anymore
        l = logging.getLogger('RepTate')
        if CmdBase.mode == CmdMode.GUI:
            l.error(tb_msg.replace('\n', '<br>'))
        else:
            l.error(tb_msg)
        msg = 'Sorry, something went wrong:\n \"%s: %s\".\nTry to save your work and quit RepTate.\nDo you want to help RepTate developers by reporting this bug?' % (
            type.__name__, str(value))
        ans = QMessageBox.critical(ex, 'Critical Error', msg,
                                   QMessageBox.Yes | QMessageBox.No)
        if ans == QMessageBox.Yes:
            address = "*****@*****.**"
            subject = "Something went wrong"
            body = "%s\nIf you can, please describe below what you were doing with RepTate when the error happened (apps and theories or tools open if any) and send the message\nPlease, do NOT include confidential information\n%s\nError Traceback:\n %s" % (
                "-" * 60, "-" * 60 + "\n" * 10 + "-" * 60, tb_msg)
            QDesktopServices.openUrl(
                QUrl(
                    "mailto:?to=%s&subject=%s&body=%s" %
                    (address, subject, body), QUrl.TolerantMode))

    sys.excepthook = my_excepthook

    ex.showMaximized()
    sys.exit(app.exec_())
Esempio n. 8
0
def start_RepTate(argv):
    """
    Main RepTate application. 
    
    :param list argv: Command line parameters passed to Reptate
    """
    loglevel = logging.DEBUG
    GUI = True
    QApplication.setStyle("Fusion")  # comment that line for a native look
    # for a list of available styles: "from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys())"

    app = QApplication(sys.argv)

    # FOR DEBUGGING PURPOSES: Set Single or MultiThread (default)
    CmdBase.calcmode = CalcMode.singlethread

    ex = QApplicationManager(loglevel=loglevel)
    ex.setStyleSheet("QTabBar::tab { color:black; height: 22px; }")

    ex.show()

    ########################################################
    # THE FOLLOWING LINES ARE FOR TESTING A PARTICULAR CASE
    # Open a particular application

    ####################
    # open linear rheology data to import the Maxwell modes
    ex.handle_new_app("LVE")
    dow_dir = "data%sDOW%sLinear_Rheology_TTS%s" % ((os.sep, ) * 3)
    ex.applications["LVE1"].new_tables_from_files([
        dow_dir + "DOWLDPEL150R_160C.tts",
    ])
    ex.applications["LVE1"].datasets["Set1"].new_theory("Maxwell Modes")
    ex.applications["LVE1"].datasets["Set1"].handle_actionMinimize_Error()

    #####################
    # TEST Rolie-Poly
    # Open a Dataset

    ex.handle_new_app("NLVE")

    dow_dir = "data%sDOW%sNon-Linear_Rheology%sStart-up_Shear%s" % (
        (os.sep, ) * 4)
    ex.applications["NLVE2"].new_tables_from_files([
        dow_dir + "My_dow150-160-1 shear.shear",
        dow_dir + "My_dow150-160-01 shear.shear",
        dow_dir + "My_dow150-160-001 shear.shear",
        dow_dir + "My_dow150-160-3 shear.shear",
        dow_dir + "My_dow150-160-03 shear.shear",
        dow_dir + "My_dow150-160-003 shear.shear",
        dow_dir + "My_dow150-160-0003 shear.shear",
    ])
    # Open a theory
    ex.applications["NLVE2"].datasets["Set1"].new_theory("Rolie-Poly")
    # Minimize the theory
    # Copy Maxwell Modes
    ex.applications["NLVE2"].datasets["Set1"].theories["RP1"].do_copy_modes(
        "LVE1.Set1.MM1")
    ex.applications["NLVE2"].datasets["Set1"].handle_actionMinimize_Error()

    #####################
    # TEST Rolie-Poly uniaxial extension
    # Open a Dataset
    ex.handle_new_app("NLVE")
    dow_dir = "data%sDOW%sNon-Linear_Rheology%sStart-up_extension%s" % (
        (os.sep, ) * 4)
    ex.applications["NLVE3"].new_tables_from_files([
        dow_dir + "My_dow150-160-01.uext",
        dow_dir + "My_dow150-160-001.uext",
        dow_dir + "My_dow150-160-0001.uext",
        dow_dir + "My_dow150-160-03.uext",
        dow_dir + "My_dow150-160-003.uext",
        dow_dir + "My_dow150-160-0003.uext",
    ])

    # Open a theory
    ex.applications["NLVE3"].datasets["Set1"].new_theory("Rolie-Poly")
    # select uniaxial extension
    ex.applications["NLVE3"].datasets["Set1"].theories[
        "RP1"].select_extensional_flow()
    # Copy Maxwell Modes
    ex.applications["NLVE3"].datasets["Set1"].theories["RP1"].do_copy_modes(
        "LVE1.Set1.MM1")
    # Minimize the theory
    ex.applications["NLVE3"].datasets["Set1"].handle_actionMinimize_Error()

    # Open a theory
    ex.applications["NLVE3"].datasets["Set1"].new_theory("Pom-Pom")

    sys.exit(app.exec_())